添加人员考勤记录获取
This commit is contained in:
parent
17618cc0ad
commit
b9ee5aef43
|
|
@ -50,7 +50,7 @@ public class TbProConfigServiceImpl implements TbProConfigService {
|
|||
}
|
||||
int num=mapper.getProConfig(params);
|
||||
if(num>0){
|
||||
return AjaxResult.error("当前分包商配置已存在,请去修改");
|
||||
return AjaxResult.error("当前分公司配置已存在,请去修改");
|
||||
}
|
||||
List<String> proTypeList= Arrays.asList(proType.split(","));
|
||||
List<String> proAreaList= Arrays.asList(proArea.split(","));
|
||||
|
|
@ -84,7 +84,7 @@ public class TbProConfigServiceImpl implements TbProConfigService {
|
|||
}
|
||||
int num=mapper.getProConfig(params);
|
||||
if(num>0){
|
||||
return AjaxResult.error("当前分包商配置已存在,请去修改");
|
||||
return AjaxResult.error("当前分公司配置已存在,请去修改");
|
||||
}
|
||||
List<String> proTypeList= Arrays.asList(proType.split(","));
|
||||
List<String> proAreaList= Arrays.asList(proArea.split(","));
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ public class ReceiveCmd {
|
|||
case "CLEAR_LOG_DATA":
|
||||
service.clearLogData(task, req, resp);
|
||||
break;
|
||||
case "RESET_LOG_MARK":
|
||||
service.resetLogMark(task, req, resp);
|
||||
break;
|
||||
case "GET_DEVICE_INFO":
|
||||
service.getDeviceInfo(task, req, resp);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class ResultHandle {
|
|||
String isok = req.getHeader("cmd_return_code");
|
||||
try{
|
||||
KqCmdTaskVo taskVo=service.getTaskVoById(asTransId);
|
||||
taskVo.setDeviceName(deviceVo.getDeviceName());
|
||||
//存在任务
|
||||
if(taskVo!=null){
|
||||
//任务失败了
|
||||
|
|
@ -76,7 +77,7 @@ public class ResultHandle {
|
|||
break;
|
||||
case "GET_LOG_DATA":
|
||||
// 获取记录数据
|
||||
service.insertLogData(taskVo, req, resp);
|
||||
isClose= service.insertLogData(taskVo, req, resp);
|
||||
break;
|
||||
case "GET_DEVICE_INFO":
|
||||
// 获取设备基本信息
|
||||
|
|
@ -95,8 +96,18 @@ public class ResultHandle {
|
|||
// 删除人员的反馈
|
||||
service.insertDeleteUser(taskVo, req, resp);
|
||||
break;
|
||||
case "RESET_LOG_MARK":
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
// 获取设备基本信息
|
||||
// deviceManage.insertDeviceInfo(task, req, resp);
|
||||
break;
|
||||
default:
|
||||
taskVo.setMsg("未知命令");
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
break;
|
||||
}
|
||||
if(isClose){
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class UserFaceHandle {
|
|||
//验证用户是否入场
|
||||
BmWorkerEinUserVo vo=service.getOnUserInfo(userId,proId);
|
||||
if(vo==null){
|
||||
vo=createAttendanceVo(deviceVo,userId,devCode,time,bast64);
|
||||
vo=createAttendanceVo(deviceVo,userId,devCode,time,bast64);
|
||||
vo.setAttDay(attDay);
|
||||
vo.setAttMonth(month);
|
||||
service.addWrcUser(vo);
|
||||
|
|
@ -110,6 +110,50 @@ public class UserFaceHandle {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增人员考勤信息-只添加考勤打卡
|
||||
* @param userId
|
||||
* @param
|
||||
*/
|
||||
public void addUserInfo(String userId,String devCode,String time,String bast64,String deviceName) {
|
||||
try{
|
||||
DeviceVo deviceVo=new DeviceVo();
|
||||
deviceVo.setDevCode(devCode);
|
||||
deviceVo.setDeviceName(deviceName);
|
||||
DateTime datetime= DateUtil.parse(time, DatePattern.PURE_DATETIME_FORMAT);
|
||||
String attDay= YMD_SDF.format(datetime);
|
||||
String month=MM_SDF.format(datetime);
|
||||
//考情机是否绑定工程
|
||||
String proId=service.getDevPorId(devCode);
|
||||
if(StringUtils.isNotEmpty(proId)){
|
||||
//验证用户是否入场
|
||||
BmWorkerEinUserVo vo=service.getOnUserInfo(userId,proId);
|
||||
if(vo==null){
|
||||
// vo=createAttendanceVo(deviceVo,userId,devCode,time,bast64);
|
||||
// vo.setAttDay(attDay);
|
||||
// vo.setAttMonth(month);
|
||||
// service.addWrcUser(vo);
|
||||
}else {
|
||||
vo.setAttDay(attDay);
|
||||
vo.setAttMonth(month);
|
||||
vo.setAttPhoto(bast64);
|
||||
vo.setAttTime(time);
|
||||
vo.setDevCode(devCode);
|
||||
vo.setDevName(deviceVo.getDeviceName());
|
||||
service.addAttendInfo(vo);
|
||||
//数据返回
|
||||
}
|
||||
}else{
|
||||
// BmWorkerEinUserVo vo=createAttendanceVo(deviceVo,userId,devCode,time,bast64);
|
||||
// service.addWrcUser(vo);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private BmWorkerEinUserVo createAttendanceVo(DeviceVo deviceVo, String userId, String devCode,
|
||||
String time, String base64Photo) {
|
||||
BmWorkerEinUserVo vo = new BmWorkerEinUserVo();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ public class CmdLogService {
|
|||
if(body.length()>4000){
|
||||
body=body.substring(0,4000);
|
||||
}
|
||||
mapper.insertCmdLogs(taskVo,body);
|
||||
if(!"default".equals(taskVo.getId())){
|
||||
mapper.insertCmdLogs(taskVo,body);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.bonus.common.core.utils.StringUtils;
|
|||
import com.bonus.common.core.urk.CommonUtils;
|
||||
import com.bonus.common.core.urk.Constant;
|
||||
import com.bonus.system.api.model.UploadFileVo;
|
||||
import com.bonus.urk.handle.UserFaceHandle;
|
||||
import com.bonus.urk.mapper.ResultMapper;
|
||||
import com.bonus.urk.minio.UrkMinioService;
|
||||
import com.bonus.urk.vo.*;
|
||||
|
|
@ -36,6 +37,9 @@ public class ResultService {
|
|||
@Resource
|
||||
private UrkMinioService fileService;
|
||||
|
||||
@Resource
|
||||
private UserFaceHandle userFaceHandle;
|
||||
|
||||
/**
|
||||
* 查询任务 记录
|
||||
* @param asTransId
|
||||
|
|
@ -99,20 +103,47 @@ public class ResultService {
|
|||
* @param req
|
||||
* @param resp
|
||||
*/
|
||||
public void insertLogData(KqCmdTaskVo taskVo, HttpServletRequest req, HttpServletResponse resp) {
|
||||
public boolean insertLogData(KqCmdTaskVo taskVo, HttpServletRequest req, HttpServletResponse resp) {
|
||||
String packageId="0";
|
||||
try {
|
||||
// 解析request输入流
|
||||
String jsonStr = getRequestBody(req);
|
||||
log.info("设备记录数据:{}", jsonStr);
|
||||
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
if(StringUtils.isNotBlank(jsonStr)) {
|
||||
//数据处理
|
||||
JSONObject json=JSON.parseObject(jsonStr);
|
||||
List<DevUserVo> list=new ArrayList<>();
|
||||
JSONArray logs=json.getJSONArray("logs");
|
||||
packageId=json.getString("packageId");
|
||||
if(logs!=null && !logs.isEmpty()) {
|
||||
//获取数据
|
||||
for (int i = 0; i < logs.size(); i++) {
|
||||
String deviceCode=taskVo.getDeviceCode();
|
||||
//打卡人
|
||||
String userId=logs.getJSONObject(i).getString("userId");
|
||||
//打卡时间
|
||||
String time=logs.getJSONObject(i).getString("time");
|
||||
String photo=logs.getJSONObject(i).getString("logPhoto");
|
||||
//添加人员考勤打卡数据
|
||||
userFaceHandle.addUserInfo(userId,deviceCode,time,photo,taskVo.getDeviceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
//考勤数据查询
|
||||
if("0".equals(packageId)){
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
return true;
|
||||
}else{
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.getWriter().write("");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void insertDeviceInfo(KqCmdTaskVo taskVo, HttpServletRequest req, HttpServletResponse resp) {
|
||||
|
|
@ -174,7 +205,7 @@ public class ResultService {
|
|||
String packageId="0";
|
||||
// 解析request输入流
|
||||
String jsonStr = getRequestBody(req);
|
||||
log.info("获取设备用户信息:{}", jsonStr);
|
||||
// log.info("获取设备用户信息:{}", jsonStr);
|
||||
if(StringUtils.isNotBlank(jsonStr)) {
|
||||
//数据处理
|
||||
JSONObject json=JSON.parseObject(jsonStr);
|
||||
|
|
@ -234,6 +265,9 @@ public class ResultService {
|
|||
try{
|
||||
List<String> userIds=mapper.getTaskUser(taskVo.getId());
|
||||
mapper.delKqDevUser(userIds,taskVo.getDeviceCode());
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -253,6 +287,9 @@ public class ResultService {
|
|||
//将人员数据同步到考勤人员里面去
|
||||
List<String> userIds=mapper.getTaskUser(taskVo.getId());
|
||||
mapper.insertKqDevUserList(userIds,taskVo.getDeviceCode());
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, taskVo.getId());
|
||||
resp.getWriter().write("");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
|
|
@ -34,6 +35,7 @@ import java.io.InputStream;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -199,44 +201,49 @@ public class TaskService {
|
|||
* @param resp
|
||||
*/
|
||||
public void getLogList(DeviceTaskVo task, HttpServletRequest req, HttpServletResponse resp) {
|
||||
String body = "";
|
||||
//请求参数
|
||||
String cmdParam=task.getCmdParam();
|
||||
if(StringHelper.isNullOrEmptyString(cmdParam)){
|
||||
String msg = "获取记录数据请求用户发送数据为空,不能处理";
|
||||
log.error(msg);
|
||||
task.setTransStatus(TaskStatusEnum.ERROR.ordinal());
|
||||
task.setMsg(msg);
|
||||
mapper.updateById(task);
|
||||
return;
|
||||
}
|
||||
//转成json
|
||||
JSONObject json=JSONObject.parseObject(cmdParam);
|
||||
String startTime=json.getString("startTime");
|
||||
String endTime=json.getString("endTime");
|
||||
String clearMark=json.getString("clearMark");
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("beginTime", sdf.format(startTime));
|
||||
jsonObject.put("endTime", sdf.format(endTime));
|
||||
if(!StringHelper.isNullOrEmptyString(clearMark)){
|
||||
jsonObject.put("clearMark", clearMark);
|
||||
}
|
||||
body = jsonObject.toString();
|
||||
try {
|
||||
// body
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.setCharacterEncoding(Constant.CHART_SET);
|
||||
resp.setContentType("application/octet-stream");
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, task.getId());
|
||||
resp.addHeader("cmd_code", task.getCmdCode());
|
||||
resp.getWriter().write(body);
|
||||
} catch (Exception e) {
|
||||
try{
|
||||
// 1. 定义日期格式(与 JSON 中的 startTime/endTime 格式保持一致,关键!)
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String body = "";
|
||||
//请求参数
|
||||
String cmdParam=task.getCmdParam();
|
||||
if(StringHelper.isNullOrEmptyString(cmdParam)){
|
||||
String msg = "获取记录数据请求用户发送数据为空,不能处理";
|
||||
log.error(msg);
|
||||
task.setTransStatus(TaskStatusEnum.ERROR.ordinal());
|
||||
task.setMsg(msg);
|
||||
mapper.updateById(task);
|
||||
return;
|
||||
}
|
||||
//转成json
|
||||
JSONObject json=JSONObject.parseObject(cmdParam);
|
||||
Date startDate = dateFormat.parse(json.getString("startTime"));
|
||||
Date endDate = dateFormat.parse(json.getString("endTime"));
|
||||
String clearMark=json.getString("clearMark");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("beginTime", sdf.format(startDate));
|
||||
jsonObject.put("endTime", sdf.format(endDate));
|
||||
if(!StringHelper.isNullOrEmptyString(clearMark)){
|
||||
jsonObject.put("clearMark", clearMark);
|
||||
}
|
||||
body = jsonObject.toString();
|
||||
try {
|
||||
// body
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.setCharacterEncoding(Constant.CHART_SET);
|
||||
resp.setContentType("application/octet-stream");
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, task.getId());
|
||||
resp.addHeader("cmd_code", task.getCmdCode());
|
||||
resp.getWriter().write(body);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 获取记录数据指令下达", task.getDeviceCode());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 获取记录数据指令下达", task.getDeviceCode());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,6 +266,46 @@ public class TaskService {
|
|||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 删除所有记录指令下达", task.getDeviceCode());
|
||||
|
||||
}
|
||||
/**
|
||||
* 重置实时打卡数据标志
|
||||
* @param task
|
||||
* @param req
|
||||
* @param resp
|
||||
*/
|
||||
public void resetLogMark(DeviceTaskVo task, HttpServletRequest req, HttpServletResponse resp) {
|
||||
String body = "";
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
//请求参数
|
||||
String cmdParam=task.getCmdParam();
|
||||
if(StringHelper.isNullOrEmptyString(cmdParam)){
|
||||
String msg = "重置参数为空不能处理,不能处理";
|
||||
log.error(msg);
|
||||
task.setTransStatus(TaskStatusEnum.ERROR.ordinal());
|
||||
task.setMsg(msg);
|
||||
mapper.updateById(task);
|
||||
return;
|
||||
}
|
||||
//转成json
|
||||
JSONObject json= JSON.parseObject(cmdParam);
|
||||
Date startDate = dateFormat.parse(json.getString("startTime"));
|
||||
Date endDate = dateFormat.parse(json.getString("endTime"));
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("beginTime", sdf.format(startDate));
|
||||
jsonObject.put("endTime", sdf.format(endDate));
|
||||
body = jsonObject.toString();
|
||||
resp.addHeader(Constant.DEVICE_HEADER_RESPONSE_CODE, Constant.OK);
|
||||
resp.setCharacterEncoding(Constant.CHART_SET);
|
||||
resp.addHeader(Constant.DEVICE_HEADER_TRANS_ID, task.getId());
|
||||
resp.addHeader("cmd_code", task.getCmdCode());
|
||||
resp.getWriter().write(body);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
service.logServerResponseLog(task, resp, body);
|
||||
log.info("设备:{}, 重置实时打卡数据标志", task.getDeviceCode());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import lombok.Data;
|
|||
public class KqCmdTaskVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String deviceName;
|
||||
/**
|
||||
* 指令编码
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue