打卡数据推送
This commit is contained in:
parent
01d0512fee
commit
0c2994734f
|
|
@ -6,8 +6,10 @@ import com.engine.zhuyou.service.CommonFormModeService;
|
||||||
import com.engine.zhuyou.service.impl.CommonFormModeServiceImpl;
|
import com.engine.zhuyou.service.impl.CommonFormModeServiceImpl;
|
||||||
import com.engine.zhuyou.util.BzExcelExpUtil;
|
import com.engine.zhuyou.util.BzExcelExpUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.general.BaseBean;
|
import weaver.general.BaseBean;
|
||||||
import weaver.general.Util;
|
import weaver.general.Util;
|
||||||
|
|
@ -17,6 +19,7 @@ import weaver.hrm.User;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
|
|
@ -25,6 +28,7 @@ import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.StreamingOutput;
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -38,6 +42,36 @@ public class CommonFormModeController {
|
||||||
return ServiceUtil.getService(CommonFormModeServiceImpl.class, user);
|
return ServiceUtil.getService(CommonFormModeServiceImpl.class, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理打卡推送数据
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/handlePushData")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String handlePushData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
BaseBean baseBean = new BaseBean();
|
||||||
|
baseBean.writeLog("handlePushData go.");
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
Map<String, Object> params = ParamUtil.request2Map(request);
|
||||||
|
baseBean.writeLog("handlePushData params is:" + params);
|
||||||
|
if (CollectionUtils.isEmpty(params)) {
|
||||||
|
resultMap.put("errCode", "00");
|
||||||
|
resultMap.put("errMes", "params is null.");
|
||||||
|
return new Gson().toJson(resultMap);
|
||||||
|
}
|
||||||
|
User user = new User();
|
||||||
|
user.setUid(1);
|
||||||
|
|
||||||
|
resultMap = commonFormModeService(user).handlePushData(params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
baseBean.writeLog("handlePushData error:" + e);
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData error:" + e);
|
||||||
|
}
|
||||||
|
return new Gson().toJson(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取历史花名册数据
|
* 获取历史花名册数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,12 @@ public interface CommonFormModeService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getAllState(Map<String, Object> param);
|
Map<String, Object> getAllState(Map<String, Object> param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理打卡推送数据
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Object> handlePushData(Map<String, Object> param);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,25 @@
|
||||||
package com.engine.zhuyou.service.impl;
|
package com.engine.zhuyou.service.impl;
|
||||||
|
|
||||||
import com.engine.core.impl.Service;
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.jz.util.CommonUtil;
|
||||||
import com.engine.zhuyou.service.CommonFormModeService;
|
import com.engine.zhuyou.service.CommonFormModeService;
|
||||||
import com.weaver.general.BaseBean;
|
import com.weaver.general.BaseBean;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import weaver.common.DateUtil;
|
import weaver.common.DateUtil;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
import weaver.general.Util;
|
import weaver.general.Util;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.YearMonth;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CommonFormModeServiceImpl extends Service implements CommonFormModeService {
|
public class CommonFormModeServiceImpl extends Service implements CommonFormModeService {
|
||||||
|
|
||||||
|
|
@ -226,6 +235,130 @@ public class CommonFormModeServiceImpl extends Service implements CommonFormMode
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> handlePushData(Map<String, Object> param) {
|
||||||
|
bb.writeLog("handlePushData start.");
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
String ip = Util.null2String(param.get("ip"));
|
||||||
|
if (StringUtils.isEmpty(ip)) {
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData ip is null.");
|
||||||
|
bb.writeLog("handlePushData ip is null.");
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
Object dataObj = param.get("data");
|
||||||
|
if (dataObj == null || dataObj == "") {
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData data is null.");
|
||||||
|
bb.writeLog("handlePushData data is null.");
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
List<Map<String, String>> dataMapList = (List<Map<String, String>>) dataObj;
|
||||||
|
if (CollectionUtils.isEmpty(dataMapList)) {
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData dataMapList is null.");
|
||||||
|
bb.writeLog("handlePushData dataMapList is null.");
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
// 获取工号与id对应
|
||||||
|
Map<String, String> ghAndIdMap = new HashMap<>();
|
||||||
|
rs.execute("SELECT id, workcode FROM hrmresource WHERE workcode is not null");
|
||||||
|
while (rs.next()) {
|
||||||
|
String id = rs.getString("id");
|
||||||
|
String workcode = rs.getString("workcode");
|
||||||
|
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(workcode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ghAndIdMap.put(workcode, id);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(ghAndIdMap)) {
|
||||||
|
bb.writeLog("handlePushData ghAndIdMap is null.");
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData ghAndIdMap is null.");
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
// 获取老数据去重
|
||||||
|
Set<String> oldDataSet = new HashSet<>();
|
||||||
|
YearMonth ny = YearMonth.now();
|
||||||
|
String ksrq = ny.minusMonths(2) + "-01";
|
||||||
|
rs.execute("SELECT transactionid, person_code FROM uf_ysdkjl WHERE signtime >= '" + ksrq + "'");
|
||||||
|
while (rs.next()) {
|
||||||
|
String transactionid = rs.getString("transactionid");
|
||||||
|
String person_code = rs.getString("person_code");
|
||||||
|
if (StringUtils.isEmpty(transactionid) || StringUtils.isEmpty(person_code)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
oldDataSet.add(transactionid + "_" + person_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<List> insertParams = new ArrayList<>();
|
||||||
|
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
|
||||||
|
for (Map<String, String> map : dataMapList) {
|
||||||
|
String id = map.get("id");
|
||||||
|
if (StringUtils.isEmpty(id)) {
|
||||||
|
id = "";
|
||||||
|
}
|
||||||
|
String pers_person_name = map.get("pers_person_name");
|
||||||
|
String pers_person_pin = map.get("pers_person_pin");
|
||||||
|
if (StringUtils.isEmpty(pers_person_pin)) {
|
||||||
|
pers_person_pin = "";
|
||||||
|
}
|
||||||
|
String att_datetime = map.get("att_datetime");
|
||||||
|
String machine_no = map.get("machine_no");
|
||||||
|
String mark = map.get("mark");
|
||||||
|
String update_time = map.get("update_time");
|
||||||
|
|
||||||
|
if ((!CollectionUtils.isEmpty(oldDataSet)) && oldDataSet.contains(id + "_" + pers_person_pin)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List insertParam = new ArrayList<>();
|
||||||
|
insertParam.add(att_datetime);
|
||||||
|
insertParam.add(pers_person_name);
|
||||||
|
insertParam.add(pers_person_pin);
|
||||||
|
insertParam.add(machine_no);
|
||||||
|
insertParam.add(mark);
|
||||||
|
insertParam.add(update_time);
|
||||||
|
insertParam.add(id);
|
||||||
|
insertParam.add(machine_no);
|
||||||
|
insertParam.add(ip);
|
||||||
|
insertParam.add("95");
|
||||||
|
insertParam.add("141");
|
||||||
|
insertParam.add("1");
|
||||||
|
insertParam.add("0");
|
||||||
|
insertParam.add(sdfDate.format(new Date()));
|
||||||
|
insertParam.add(sdfTime.format(new Date()));
|
||||||
|
insertParams.add(insertParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (org.springframework.util.CollectionUtils.isEmpty(insertParams)) {
|
||||||
|
bb.writeLog("handlePushData insertParams is null.");
|
||||||
|
} else {
|
||||||
|
String insertSql = "INSERT INTO uf_ysdkjl (signtime,person_name,person_code,machine_no,mark,storets,transactionid," +
|
||||||
|
"deviceid,ip,formmodeid,MODEUUID, modedatacreater,modedatacreatertype, modedatacreatedate," +
|
||||||
|
" modedatacreatetime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
rs.executeBatchSql(insertSql, insertParams);
|
||||||
|
//权限重构
|
||||||
|
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
||||||
|
modeRightInfo.setNewRight(true);
|
||||||
|
modeRightInfo.editModeDataShare(1, 95, 141);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
bb.writeLog("handlePushData error:" + e);
|
||||||
|
resultMap.put("errCode", "01");
|
||||||
|
resultMap.put("errMes", "handlePushData error is:" + e);
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
resultMap.put("errCode", "00");
|
||||||
|
resultMap.put("errMes", "handlePushData end.");
|
||||||
|
bb.writeLog("handlePushData end.");
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
private String getSelectNameMain(String fieldName, String billid, String selectValue) {
|
private String getSelectNameMain(String fieldName, String billid, String selectValue) {
|
||||||
RecordSet rs = new RecordSet();
|
RecordSet rs = new RecordSet();
|
||||||
rs.executeQuery("select id from workflow_billfield where fieldname = ? and billid = ? and viewtype=0", fieldName, billid);
|
rs.executeQuery("select id from workflow_billfield where fieldname = ? and billid = ? and viewtype=0", fieldName, billid);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue