generated from dxfeng/secondev-chapanda-feishu
1318 lines
62 KiB
Java
1318 lines
62 KiB
Java
package com.engine.recruit.service.impl;
|
||
|
||
import cn.hutool.core.convert.Convert;
|
||
import cn.hutool.http.Header;
|
||
import cn.hutool.http.HttpRequest;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.engine.core.impl.Service;
|
||
import com.engine.kq.biz.KQFormatBiz;
|
||
import com.engine.kq.wfset.util.SplitActionUtil;
|
||
import com.engine.recruit.conn.ApplicantCommonInfo;
|
||
import com.engine.recruit.constant.RecruitConstant;
|
||
import com.engine.recruit.entity.common.ImportLog;
|
||
import com.engine.recruit.exception.CustomizeRunTimeException;
|
||
import com.engine.recruit.service.WrittenResultsService;
|
||
import com.engine.recruit.util.EncryptAndDecryptUtil;
|
||
import com.engine.recruit.util.ExcelUtil;
|
||
import com.google.gson.Gson;
|
||
import com.google.gson.reflect.TypeToken;
|
||
import org.apache.commons.collections.MapUtils;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
import org.apache.http.HttpEntity;
|
||
import org.apache.http.HttpResponse;
|
||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||
import org.apache.http.client.methods.HttpGet;
|
||
import org.apache.http.client.methods.HttpPost;
|
||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
|
||
import org.apache.http.entity.StringEntity;
|
||
import org.apache.http.impl.client.CloseableHttpClient;
|
||
import org.apache.http.impl.client.HttpClients;
|
||
import org.apache.http.ssl.SSLContexts;
|
||
import org.apache.http.util.EntityUtils;
|
||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||
import org.springframework.util.Assert;
|
||
import org.springframework.util.CollectionUtils;
|
||
import weaver.conn.RecordSet;
|
||
import weaver.file.ImageFileManager;
|
||
import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil;
|
||
import weaver.general.BaseBean;
|
||
import weaver.general.Util;
|
||
|
||
import java.io.IOException;
|
||
import java.lang.reflect.Type;
|
||
import java.math.BigDecimal;
|
||
import java.text.SimpleDateFormat;
|
||
import java.time.Instant;
|
||
import java.time.LocalDate;
|
||
import java.time.LocalDateTime;
|
||
import java.time.ZoneId;
|
||
import java.time.ZonedDateTime;
|
||
import java.time.format.DateTimeFormatter;
|
||
import java.util.*;
|
||
import java.util.concurrent.ExecutorService;
|
||
import java.util.concurrent.Executors;
|
||
|
||
/**
|
||
* @author:dxfeng
|
||
* @createTime: 2024/01/24
|
||
* @version: 1.0
|
||
*/
|
||
public class WrittenResultsServiceImpl extends Service implements WrittenResultsService {
|
||
@Override
|
||
public Map<String, Object> getFormCondition() {
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> importExcel(Map<String, Object> params) {
|
||
Integer excelId = Convert.toInt(params.get("excel"));
|
||
ImageFileManager manager = new ImageFileManager();
|
||
manager.getImageFileInfoById(excelId);
|
||
|
||
XSSFWorkbook workbook;
|
||
try {
|
||
workbook = new XSSFWorkbook(manager.getInputStream());
|
||
} catch (IOException e) {
|
||
throw new CustomizeRunTimeException(e);
|
||
}
|
||
// 当前sheet
|
||
XSSFSheet sheetAt = workbook.getSheetAt(0);
|
||
// 最后一行
|
||
int lastRowNum = sheetAt.getLastRowNum();
|
||
if (lastRowNum < 1) {
|
||
throw new CustomizeRunTimeException("导入数据为空");
|
||
}
|
||
// 最后一列
|
||
short lastCellNum = sheetAt.getRow(0).getLastCellNum();
|
||
Map<String, Integer> keyMap = new HashMap<>(16);
|
||
// 标题行
|
||
for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) {
|
||
XSSFRow row = sheetAt.getRow(0);
|
||
if (row == null) {
|
||
throw new CustomizeRunTimeException("表单字段名称获取失败,请检查Excel文件");
|
||
}
|
||
XSSFCell cell = row.getCell((short) cellIndex);
|
||
String cellValue = ExcelUtil.getCellValue(cell).trim();
|
||
keyMap.put(cellValue, cellIndex);
|
||
}
|
||
// 校验必填列
|
||
checkRequiredFields(keyMap, "ID", "笔试成绩", "笔试结果");
|
||
|
||
Integer idCellNum = keyMap.get("ID");
|
||
Integer scoreCellNum = keyMap.get("笔试成绩");
|
||
Integer resultCellNum = keyMap.get("笔试结果");
|
||
|
||
return updateWrittenResult(sheetAt, lastRowNum, idCellNum, scoreCellNum, resultCellNum);
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> remindExaminer(Map<String, Object> params) {
|
||
Map<String, Object> resultMap = new HashMap<>();
|
||
BaseBean baseBean = new BaseBean();
|
||
baseBean.writeLog("remindExaminer start:" + params);
|
||
try {
|
||
String sjh = Util.null2String(params.get("sjh"));
|
||
if (StringUtils.isEmpty(sjh)) {
|
||
return resultMap;
|
||
}
|
||
RecordSet rs = new RecordSet();
|
||
// 获取建模id和表单id
|
||
String modeId = null;
|
||
String formId = null;
|
||
rs.execute("SELECT a.id AS modeId, b.id AS formId, b.tablename FROM modeinfo a " +
|
||
" LEFT JOIN workflow_bill b ON a.formid = b.id WHERE b.tablename = 'uf_jcl_bs'");
|
||
if (rs.next()) {
|
||
modeId = rs.getString("modeId");
|
||
formId = rs.getString("formId");
|
||
}
|
||
rs.executeQuery("SELECT a.id, a.bsg, b.lastname, c.xm, d.zpzwmc FROM uf_jcl_bs a " +
|
||
" LEFT JOIN hrmresource b ON a.bsg = b.id " +
|
||
" LEFT JOIN uf_jcl_yppc c ON a.ypz = c.id " +
|
||
" LEFT JOIN uf_jcl_zp_zpzw d ON a.ypzw = d.id " +
|
||
" WHERE a.sjh = ?", sjh);
|
||
while (rs.next()) {
|
||
String id = rs.getString("id");
|
||
String bsg = rs.getString("bsg");
|
||
String lastname = rs.getString("lastname");
|
||
String xm = rs.getString("xm");
|
||
String zpzwmc = rs.getString("zpzwmc");
|
||
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(bsg) || StringUtils.isEmpty(lastname) || StringUtils.isEmpty(xm) || StringUtils.isEmpty(zpzwmc)) {
|
||
continue;
|
||
}
|
||
Set<String> applicantSet = new HashSet<>();
|
||
applicantSet.add(bsg);
|
||
// 获取消息类型默认值
|
||
String messageType = RecruitConstant.RECRUIT_MESSAGE_TYPE;
|
||
|
||
String title = "【笔试阅卷提醒】";
|
||
|
||
String url = "/spa/cube/index.html#/main/cube/card?type=0&modeId=" + modeId + "&formId=" + formId + "&billid=" + id;
|
||
String content = lastname + "您好,应聘" + zpzwmc + "职位的" + xm + "已完成笔试答卷上传,请尽快前往【招聘管理-笔试】中进行笔试答卷的下载以及笔试结果录入。";
|
||
String mobileUrl = "/mobilemode/browserLinkTransit.jsp?billid=" + id + "&modeId=" + modeId + "&formId=" + formId;
|
||
// 消息提醒
|
||
RecruitModeUtil.messagePush(messageType, title, content, applicantSet, 1, url, mobileUrl);
|
||
}
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("remindExaminer error:" + e);
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> countOption(Map<String, Object> params) {
|
||
Map<String, Object> resultMap = new HashMap<>();
|
||
BaseBean baseBean = new BaseBean();
|
||
baseBean.writeLog("countOption start:" + params);
|
||
try {
|
||
String sjh = Util.null2String(params.get("sjh"));
|
||
// 提交一个 Runnable 任务到 ExecutorService
|
||
Executors.newSingleThreadExecutor().submit(() -> {
|
||
handleCountOption(sjh);
|
||
});
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("countOption error:" + e);
|
||
}
|
||
return resultMap;
|
||
}
|
||
|
||
@Override
|
||
public Map<String, Object> getQwCardData(Map<String, Object> params) {
|
||
Map<String, Object> result = new HashMap<>();
|
||
BaseBean baseBean = new BaseBean();
|
||
RecordSet rs = new RecordSet();
|
||
baseBean.writeLog("getQwCardData start:" + params);
|
||
try {
|
||
// 开始日期
|
||
String ksrq = Util.null2String(params.get("ksrq"));
|
||
// 结束日期
|
||
String jsrq = Util.null2String(params.get("jsrq"));
|
||
if (StringUtils.isEmpty(ksrq) || StringUtils.isEmpty(jsrq)) {
|
||
baseBean.writeLog("getQwCardData date error.");
|
||
result.put("mes", "日期不能为空!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
DateTimeFormatter formatterRq = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
LocalDate date1 = LocalDate.parse(ksrq, formatterRq);
|
||
LocalDate date2 = LocalDate.parse(jsrq, formatterRq);
|
||
|
||
if (date2.isBefore(date1)) {
|
||
baseBean.writeLog("getQwCardData date error.");
|
||
result.put("mes", "结束日期不能在开始日期之前!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||
|
||
String syncIntervalMin = RecruitConstant.SYNC_INTERVAL_MIN;
|
||
if (StringUtils.isEmpty(syncIntervalMin)) {
|
||
syncIntervalMin = "10";
|
||
}
|
||
|
||
baseBean.writeLog("getQwCardData syncIntervalMin is:" + syncIntervalMin);
|
||
|
||
ZonedDateTime zonedDateTimeNow = LocalDateTime.now().atZone(ZoneId.of("Asia/Shanghai"));
|
||
long timestampNow = zonedDateTimeNow.toInstant().toEpochMilli() / 1000;
|
||
|
||
String syncIntervalSec = new BigDecimal(String.valueOf(60)).multiply(new BigDecimal(syncIntervalMin)).toString();
|
||
|
||
// 获取同步时间
|
||
String djtbsj = null;
|
||
rs.execute("SELECT TOP 1 * FROM uf_tbdjjlb ORDER BY id DESC");
|
||
if (rs.next()) {
|
||
djtbsj = rs.getString("djtbsj");
|
||
}
|
||
|
||
if (StringUtils.isNotEmpty(djtbsj) && (timestampNow - Long.parseLong(syncIntervalSec) <= Long.parseLong(djtbsj))) {
|
||
long kdj = Long.parseLong(syncIntervalSec) + Long.parseLong(djtbsj);
|
||
Instant instant = Instant.ofEpochSecond(kdj);
|
||
// 2. 指定时区(例如:上海时区)
|
||
ZonedDateTime zonedDateTimeA = instant.atZone(ZoneId.of("Asia/Shanghai"));
|
||
// 4. 转为字符串
|
||
String dateStrA = zonedDateTimeA.format(formatter);
|
||
baseBean.writeLog("getQwCardData interval not enough.");
|
||
result.put("mes", "请勿频繁点击,请于 " + dateStrA + " 后再点击!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
// 员工
|
||
String yg = Util.null2String(params.get("yg"));
|
||
String querySql = "SELECT id, workcode, lastname FROM hrmresource WHERE workcode is not null ";
|
||
if (StringUtils.isNotEmpty(yg)) {
|
||
querySql = querySql + " AND id in (" + yg + ") ";
|
||
}
|
||
|
||
// 获取人员企微userid映射
|
||
Map<String, String> qwIdMap = new HashMap<>();
|
||
rs.execute("SELECT xm, qwuserid FROM uf_zsjgxysb");
|
||
while (rs.next()) {
|
||
String xm = rs.getString("xm");
|
||
String qwuserid = rs.getString("qwuserid");
|
||
if (StringUtils.isEmpty(xm) || StringUtils.isEmpty(qwuserid)) {
|
||
continue;
|
||
}
|
||
qwIdMap.put(xm, qwuserid);
|
||
}
|
||
|
||
// 获取工号与id对应
|
||
List<String> ghList = new ArrayList<>();
|
||
Map<String, String> ghAndIdMap = new HashMap<>();
|
||
Map<String, String> ghAndNameMap = new HashMap<>();
|
||
Map<String, String> ghAndOaGhMap = new HashMap<>();
|
||
rs.execute(querySql);
|
||
while (rs.next()) {
|
||
String id = rs.getString("id");
|
||
String workcode = rs.getString("workcode");
|
||
String lastname = rs.getString("lastname");
|
||
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(lastname)) {
|
||
continue;
|
||
}
|
||
String oaGh = workcode;
|
||
if ((!CollectionUtils.isEmpty(qwIdMap)) && qwIdMap.containsKey(id)) {
|
||
workcode = qwIdMap.get(id);
|
||
}
|
||
if (StringUtils.isEmpty(workcode)) {
|
||
continue;
|
||
}
|
||
ghList.add(workcode);
|
||
ghAndIdMap.put(workcode, id);
|
||
ghAndNameMap.put(workcode, lastname);
|
||
ghAndOaGhMap.put(workcode, oaGh);
|
||
}
|
||
if (CollectionUtils.isEmpty(ghAndIdMap) || CollectionUtils.isEmpty(ghList)) {
|
||
baseBean.writeLog("getQwCardData ghAndIdMap or ghList is null.");
|
||
result.put("mes", "没有人员需要查询!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
|
||
String sql = "select * from HrmScheduleSign where belongdate = ? OR belongdate = ? ";
|
||
rs.executeQuery(sql, ksrq, jsrq);
|
||
Set<String> signSet = new HashSet<>();
|
||
while (rs.next()) {
|
||
String userId = rs.getString("userId");
|
||
String signDate = rs.getString("signDate");
|
||
String signTime = rs.getString("signTime");
|
||
String signFrom = rs.getString("signFrom");
|
||
if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(signDate) || StringUtils.isEmpty(signTime) ||StringUtils.isEmpty(signFrom)) {
|
||
continue;
|
||
}
|
||
|
||
signSet.add(userId + "_" + signDate + "_" + signTime);
|
||
}
|
||
|
||
// 获取中间表打卡数据
|
||
// getMiddleTableData(ksrq, jsrq, ghAndIdMap, signSet);
|
||
|
||
Gson gson = new Gson();
|
||
Type type = new TypeToken<Map<String, Object>>() {}.getType();
|
||
// 获取token,先考虑从缓存表中取
|
||
String jmhmw = null;
|
||
String sxsj = null;
|
||
rs.execute("SELECT TOP 1 * FROM uf_hcjlb ORDER BY id DESC");
|
||
if (rs.next()) {
|
||
jmhmw = rs.getString("jmhmw");
|
||
sxsj = rs.getString("sxsj");
|
||
}
|
||
EncryptAndDecryptUtil encryptAndDecryptUtil = new EncryptAndDecryptUtil();
|
||
zonedDateTimeNow = LocalDateTime.now().atZone(ZoneId.of("Asia/Shanghai"));
|
||
timestampNow = zonedDateTimeNow.toInstant().toEpochMilli() / 1000;
|
||
String accessToken = null;
|
||
if (StringUtils.isEmpty(jmhmw) || StringUtils.isEmpty(sxsj)) {
|
||
String tokenUrl = RecruitConstant.QW_TOKEN_URL + "?corpid=" + RecruitConstant.QW_CORPID + "&corpsecret=" + RecruitConstant.QW_CORPSECRET;
|
||
HttpGet httpGet = new HttpGet(tokenUrl);
|
||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||
String tokenRes = getString(response);
|
||
|
||
if (StringUtils.isEmpty(tokenRes)) {
|
||
baseBean.writeLog("getQwCardData tokenRes is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Map<String, Object> tokenMap = gson.fromJson(tokenRes, type);
|
||
if (CollectionUtils.isEmpty(tokenMap)) {
|
||
baseBean.writeLog("getQwCardData tokenMap is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object errcode = tokenMap.get("errcode");
|
||
if (errcode == null || errcode == "" || new BigDecimal(errcode.toString()).compareTo(BigDecimal.ZERO) != 0) {
|
||
baseBean.writeLog("getQwCardData get token failed:" + tokenMap);
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object accessTokenObj = tokenMap.get("access_token");
|
||
if (accessTokenObj == null || accessTokenObj == "") {
|
||
baseBean.writeLog("getQwCardData accessTokenObj is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object expiresIn = tokenMap.get("expires_in");
|
||
int expiresInStr = 0;
|
||
if (expiresIn != null && expiresIn != "") {
|
||
expiresInStr = ((Double)expiresIn).intValue();
|
||
}
|
||
accessToken = accessTokenObj.toString();
|
||
long sxsjLong = timestampNow + Long.parseLong(String.valueOf(expiresInStr));
|
||
rs.executeUpdate("INSERT INTO uf_hcjlb (jmhmw,sxsj) VALUES (?,?)", encryptAndDecryptUtil.encrypt(accessToken), sxsjLong);
|
||
} else {
|
||
if (new BigDecimal(String.valueOf(timestampNow)).compareTo(new BigDecimal(sxsj)) > 0) {
|
||
rs.execute("DELETE FROM uf_hcjlb");
|
||
String tokenUrl = RecruitConstant.QW_TOKEN_URL + "?corpid=" + RecruitConstant.QW_CORPID + "&corpsecret=" + RecruitConstant.QW_CORPSECRET;
|
||
HttpGet httpGet = new HttpGet(tokenUrl);
|
||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||
String tokenRes = getString(response);
|
||
|
||
if (StringUtils.isEmpty(tokenRes)) {
|
||
baseBean.writeLog("getQwCardData tokenRes is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Map<String, Object> tokenMap = gson.fromJson(tokenRes, type);
|
||
if (CollectionUtils.isEmpty(tokenMap)) {
|
||
baseBean.writeLog("getQwCardData tokenMap is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object errcode = tokenMap.get("errcode");
|
||
if (errcode == null || errcode == "" || new BigDecimal(errcode.toString()).compareTo(BigDecimal.ZERO) != 0) {
|
||
baseBean.writeLog("getQwCardData get token failed:" + tokenMap);
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object accessTokenObj = tokenMap.get("access_token");
|
||
if (accessTokenObj == null || accessTokenObj == "") {
|
||
baseBean.writeLog("getQwCardData accessTokenObj is null.");
|
||
result.put("mes", "token获取失败,请联系管理员!");
|
||
result.put("code", "400");
|
||
return result;
|
||
}
|
||
Object expiresIn = tokenMap.get("expires_in");
|
||
int expiresInStr = 0;
|
||
if (expiresIn != null && expiresIn != "") {
|
||
expiresInStr = ((Double)expiresIn).intValue();
|
||
}
|
||
accessToken = accessTokenObj.toString();
|
||
long sxsjLong = timestampNow + Long.parseLong(String.valueOf(expiresInStr));
|
||
rs.executeUpdate("INSERT INTO uf_hcjlb (jmhmw,sxsj) VALUES (?,?)", encryptAndDecryptUtil.encrypt(accessToken), sxsjLong);
|
||
} else {
|
||
accessToken = encryptAndDecryptUtil.decrypt(jmhmw);
|
||
}
|
||
}
|
||
|
||
rs.executeUpdate("INSERT INTO uf_tbdjjlb (djtbsj) VALUES (?)", timestampNow);
|
||
|
||
String start = ksrq + " 00:00:01";
|
||
String end = jsrq + " 23:59:59";
|
||
|
||
// 解析字符串为本地时间
|
||
LocalDateTime localDateTimeStart = LocalDateTime.parse(start, formatter);
|
||
LocalDateTime localDateTimeEnd = LocalDateTime.parse(end, formatter);
|
||
|
||
// 指定时区(例如:上海时区)
|
||
ZonedDateTime zonedDateTimeStart = localDateTimeStart.atZone(ZoneId.of("Asia/Shanghai"));
|
||
ZonedDateTime zonedDateTimeEnd = localDateTimeEnd.atZone(ZoneId.of("Asia/Shanghai"));
|
||
// 获取Unix时间戳(秒)
|
||
long timestampStart = zonedDateTimeStart.toInstant().toEpochMilli() / 1000;
|
||
long timestampEnd = zonedDateTimeEnd.toInstant().toEpochMilli() / 1000;
|
||
|
||
Map<String, Object> paramMap = new HashMap<>();
|
||
paramMap.put("filter_type", 1);
|
||
paramMap.put("starttime", timestampStart);
|
||
paramMap.put("endtime", timestampEnd);
|
||
|
||
baseBean.writeLog("getQwCardData ghList size is:" + ghList.size());
|
||
int batchSize = 100; // 每个小集合的大小
|
||
int size = ghList.size(); // 原始集合的大小
|
||
int numberOfBatches = (int) Math.ceil((double) size / batchSize); // 划分的小集合数量
|
||
List<List<String>> dividedLists = new ArrayList<>(); // 存储划分后的小集合
|
||
|
||
for (int i = 0; i < numberOfBatches; i++) {
|
||
int fromIndex = i * batchSize;
|
||
int toIndex = Math.min((i + 1) * batchSize, size);
|
||
List<String> batch = ghList.subList(fromIndex, toIndex);
|
||
dividedLists.add(batch);
|
||
}
|
||
|
||
// 获取设备地址
|
||
Map<String, String> sbdzMap = new HashMap<>();
|
||
rs.execute("SELECT * FROM uf_kqjtz");
|
||
while (rs.next()) {
|
||
String sbsn = rs.getString("sbsn");
|
||
String dybm = rs.getString("dybm");
|
||
if (StringUtils.isEmpty(sbsn) || StringUtils.isEmpty(dybm)) {
|
||
continue;
|
||
}
|
||
sbdzMap.put(sbsn, dybm);
|
||
}
|
||
|
||
Set<String> needFormatSet = new HashSet<>();
|
||
List<List> insertList = new ArrayList<>();
|
||
|
||
Map<String, String> mesMap = new HashMap<>();
|
||
|
||
String url = RecruitConstant.QW_CHECKIN_DATA_URL + "?access_token=" + accessToken;
|
||
for (List<String> batch : dividedLists) {
|
||
try {
|
||
paramMap.put("useridlist", batch);
|
||
baseBean.writeLog("getQwCardData paramMap is:" + JSONObject.toJSONString(paramMap));
|
||
String resultMj = doPost(url, paramMap, new HashMap<>());
|
||
// String resultMj = HttpRequest.post(url)
|
||
// .header(Header.CONTENT_TYPE, "application/json")
|
||
// .body(JSONObject.toJSONString(paramMap))
|
||
// .timeout(20000)
|
||
// .execute().body();
|
||
baseBean.writeLog("getQwCardData resultMj is:" + resultMj);
|
||
if (StringUtils.isEmpty(resultMj)) {
|
||
baseBean.writeLog("getQwCardData result is null.");
|
||
continue;
|
||
}
|
||
Map<String, Object> resultMap = gson.fromJson(resultMj, type);
|
||
if (CollectionUtils.isEmpty(resultMap)) {
|
||
baseBean.writeLog("getQwCardData resultMap is null.");
|
||
continue;
|
||
}
|
||
Object errcodeMj = resultMap.get("errcode");
|
||
if (errcodeMj == null || errcodeMj == "" || new BigDecimal(errcodeMj.toString()).compareTo(BigDecimal.ZERO) != 0) {
|
||
baseBean.writeLog("getQwCardData get mj failed:" + resultMap);
|
||
continue;
|
||
}
|
||
Object checkindataObj = resultMap.get("checkindata");
|
||
if (checkindataObj == null || checkindataObj == "") {
|
||
baseBean.writeLog("getQwCardData checkindataObj null.");
|
||
continue;
|
||
}
|
||
List<Map<String, Object>> checkinDataMapLIst = (List<Map<String, Object>>)checkindataObj;
|
||
for (Map<String, Object> checkinDataMap : checkinDataMapLIst) {
|
||
Object userId = checkinDataMap.get("userid");
|
||
Object checkinTime = checkinDataMap.get("checkin_time");
|
||
Object deviceSn = checkinDataMap.get("device_sn");
|
||
if (userId == null || userId == "" || checkinTime == null || checkinTime == "") {
|
||
continue;
|
||
}
|
||
String ygId = ghAndIdMap.get(userId.toString());
|
||
String ygName = ghAndNameMap.get(userId.toString());
|
||
if (StringUtils.isEmpty(ygId)) {
|
||
continue;
|
||
}
|
||
String fromType = "qw";
|
||
if (deviceSn != null && deviceSn != "") {
|
||
fromType = deviceSn.toString();
|
||
}
|
||
String addr = "qw";
|
||
if (deviceSn != null && deviceSn != "") {
|
||
if ((!CollectionUtils.isEmpty(sbdzMap)) && sbdzMap.containsKey(deviceSn.toString())) {
|
||
addr = sbdzMap.get(deviceSn.toString());
|
||
} else {
|
||
addr = deviceSn.toString();
|
||
}
|
||
}
|
||
Instant instant = Instant.ofEpochSecond(Long.parseLong(String.valueOf(((Double)checkinTime).intValue())));
|
||
// 2. 指定时区(例如:上海时区)
|
||
ZonedDateTime zonedDateTimeA = instant.atZone(ZoneId.of("Asia/Shanghai"));
|
||
// 4. 转为字符串
|
||
String dateStrA = zonedDateTimeA.format(formatter);
|
||
|
||
String[] dt = dateStrA.split(" ");
|
||
String rq = dt[0];
|
||
String sj = dt[1];
|
||
String keyTemp = ygId + "_" + rq + "_" + sj;
|
||
if ((!CollectionUtils.isEmpty(signSet)) && signSet.contains(keyTemp)) {
|
||
continue;
|
||
}
|
||
if ((!CollectionUtils.isEmpty(sbdzMap)) && deviceSn != null && deviceSn != "" && sbdzMap.containsKey(deviceSn.toString())) {
|
||
List list = new ArrayList();
|
||
list.add(ygId);
|
||
list.add("1");
|
||
list.add(rq);
|
||
list.add(sj);
|
||
list.add("1");
|
||
list.add(fromType);
|
||
list.add(addr);
|
||
list.add(rq);
|
||
insertList.add(list);
|
||
needFormatSet.add(ygId + "_" + rq);
|
||
|
||
mesMap.put(userId + "#" + rq + "#" + sj + "#" + ygName, addr);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("getQwCardData url error:" + e);
|
||
}
|
||
}
|
||
|
||
if (!CollectionUtils.isEmpty(insertList)) {
|
||
String insertSql = "INSERT INTO HrmScheduleSign(userId, userType, signDate, signTime, isInCom, " +
|
||
"signFrom, addr, belongdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
||
rs.executeBatchSql(insertSql, insertList);
|
||
}
|
||
|
||
// 页面手动查询的数据不进行消息推送提醒 2025-06-06
|
||
// if (!CollectionUtils.isEmpty(mesMap)) {
|
||
// // 消息推送
|
||
// pushMesToQw(mesMap, ghAndOaGhMap);
|
||
// }
|
||
|
||
if (!CollectionUtils.isEmpty(needFormatSet)) {
|
||
for (String key : needFormatSet) {
|
||
String ygId = key.split("_")[0];
|
||
String rq = key.split("_")[1];
|
||
new KQFormatBiz().formatDate(ygId, rq);
|
||
SplitActionUtil.pushOverTimeTasksAll(rq, rq, "" + ygId);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
rs.execute("DELETE FROM uf_hcjlb");
|
||
baseBean.writeLog("getQwCardData error:" + e);
|
||
result.put("mes", "系统错误,请联系管理员!");
|
||
result.put("code", "500");
|
||
return result;
|
||
}
|
||
result.put("mes", "正在同步,请稍等!");
|
||
result.put("code", "200");
|
||
return result;
|
||
}
|
||
|
||
public void pushMesToQw(Map<String, String> mesMap, Map<String, String> ghAndOaGhMap) {
|
||
BaseBean baseBean = new BaseBean();
|
||
baseBean.writeLog("pushMesToQw A start.");
|
||
RecordSet rs = new RecordSet();
|
||
String dataId = null;
|
||
try {
|
||
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
|
||
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
|
||
String uuid = UUID.randomUUID().toString();
|
||
rs.executeUpdate("INSERT INTO uf_xxtsjlglb (cs, MODEUUID, modedatacreatedate, modedatacreatetime) VALUES (?, ?, ?, ?)",
|
||
JSONObject.toJSONString(mesMap), uuid, sdfDate.format(new Date()), sdfTime.format(new Date()));
|
||
rs.executeQuery("SELECT id FROM uf_xxtsjlglb WHERE MODEUUID = ?", uuid);
|
||
if (rs.next()) {
|
||
dataId = rs.getString("id");
|
||
}
|
||
if (StringUtils.isEmpty(dataId)) {
|
||
baseBean.writeLog("pushMesToQw A get data id error:" + JSONObject.toJSONString(mesMap));
|
||
return;
|
||
}
|
||
|
||
Gson gson = new Gson();
|
||
Type type = new TypeToken<Map<String, Object>>() {}.getType();
|
||
|
||
String tokenUrl = RecruitConstant.QW_TOKEN_URL + "?corpid=" + RecruitConstant.QW_CORPID + "&corpsecret=" + RecruitConstant.QW_MES_CORPSECRET;
|
||
HttpGet httpGet = new HttpGet(tokenUrl);
|
||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||
String tokenRes = getString(response);
|
||
if (StringUtils.isEmpty(tokenRes)) {
|
||
baseBean.writeLog("pushMesToQw A tokenRes is null.");
|
||
return;
|
||
}
|
||
Map<String, Object> tokenMap = gson.fromJson(tokenRes, type);
|
||
if (CollectionUtils.isEmpty(tokenMap)) {
|
||
baseBean.writeLog("pushMesToQw A tokenMap is null.");
|
||
return;
|
||
}
|
||
Object errcode = tokenMap.get("errcode");
|
||
if (errcode == null || errcode == "" || new BigDecimal(errcode.toString()).compareTo(BigDecimal.ZERO) != 0) {
|
||
baseBean.writeLog("pushMesToQw A get token failed:" + tokenMap);
|
||
return;
|
||
}
|
||
Object accessTokenObj = tokenMap.get("access_token");
|
||
if (accessTokenObj == null || accessTokenObj == "") {
|
||
baseBean.writeLog("pushMesToQw A accessTokenObj is null.");
|
||
return;
|
||
}
|
||
// Object expiresIn = tokenMap.get("expires_in");
|
||
// int expiresInStr = 0;
|
||
// if (expiresIn != null && expiresIn != "") {
|
||
// expiresInStr = ((Double)expiresIn).intValue();
|
||
// }
|
||
String accessToken = accessTokenObj.toString();
|
||
|
||
String url = RecruitConstant.QW_MES_PUSH_URL + "?access_token=" + accessToken;
|
||
for (Map.Entry<String, String> entry : mesMap.entrySet()) {
|
||
String dtId = null;
|
||
try {
|
||
String key = entry.getKey();
|
||
String value = entry.getValue();
|
||
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) {
|
||
continue;
|
||
}
|
||
String[] keyArr = key.split("#");
|
||
String gh = keyArr[0];
|
||
String rq = keyArr[1];
|
||
String sj = keyArr[2];
|
||
String name = keyArr[3];
|
||
if (StringUtils.isEmpty(gh) || StringUtils.isEmpty(rq) || StringUtils.isEmpty(sj) || StringUtils.isEmpty(name)) {
|
||
continue;
|
||
}
|
||
String oaGh = ghAndOaGhMap.get(gh);
|
||
if (StringUtils.isEmpty(oaGh)) {
|
||
oaGh = "";
|
||
}
|
||
StringBuffer sb = new StringBuffer();
|
||
// sb.append("路维人脸识别自动打卡设备,温馨提醒您:")
|
||
// .append("\n**考勤人脸打卡信息 **")
|
||
// .append("\n日期:<font color = 'info'>").append(rq).append("</font>")
|
||
// .append("\n工号:<font color = 'warning'>").append(oaGh).append("</font>")
|
||
// .append("\n姓名:<font color = 'warning'>").append(name).append("</font>")
|
||
// .append("\n打卡时间:<font color = 'warning'>").append(rq + " " + sj).append("</font>")
|
||
// .append("\n打卡地址:<font color = 'info'>").append(value).append("</font>");
|
||
sb.append("路维人脸识别自动打卡设备,温馨提醒您:\n")
|
||
.append("**考勤人脸打卡信息 **\n")
|
||
.append("日期: <font color = \"info\">").append(rq).append("</font>\n")
|
||
.append("工号: <font color = \"warning\">").append(oaGh).append("</font>\n")
|
||
.append("姓名: <font color = \"warning\">").append(name).append("</font>\n")
|
||
.append("打卡时间: <font color = \"warning\">").append(rq + " " + sj).append("</font>\n")
|
||
.append("打卡地址: <font color = \"info\">").append(value).append("</font>\n");
|
||
Map<String, Object> paramMap = new HashMap<>();
|
||
// Map<String, Object> textMap = new HashMap<>();
|
||
// textMap.put("content", sb.toString());
|
||
JSONObject markdown = new JSONObject();
|
||
markdown.put("content", sb.toString());
|
||
paramMap.put("touser", gh);
|
||
paramMap.put("msgtype", "markdown");
|
||
paramMap.put("agentid", RecruitConstant.QW_MES_AGENTID);
|
||
paramMap.put("markdown", markdown);
|
||
String uuidDt = UUID.randomUUID() + gh;
|
||
rs.executeUpdate("INSERT INTO uf_xxtsjlglb (cs, MODEUUID, szid, modedatacreatedate, modedatacreatetime) VALUES (?, ?, ?, ?, ?)",
|
||
JSONObject.toJSONString(paramMap), uuidDt, dataId, sdfDate.format(new Date()), sdfTime.format(new Date()));
|
||
rs.executeQuery("SELECT id FROM uf_xxtsjlglb WHERE MODEUUID = ?", uuidDt);
|
||
if (rs.next()) {
|
||
dtId = rs.getString("id");
|
||
}
|
||
if (StringUtils.isEmpty(dtId)) {
|
||
baseBean.writeLog("pushMesToQw A get dt id error.");
|
||
continue;
|
||
}
|
||
String result = doPost(url, paramMap, new HashMap<>());
|
||
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET xy = ? WHERE id = ?", result, dtId);
|
||
|
||
if (StringUtils.isEmpty(result)) {
|
||
baseBean.writeLog("pushMesToQw A result is null.");
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 1 WHERE id = ?", dtId);
|
||
continue;
|
||
}
|
||
Map<String, Object> resultMap = gson.fromJson(result, type);
|
||
if (CollectionUtils.isEmpty(resultMap)) {
|
||
baseBean.writeLog("pushMesToQw A resultMap is null.");
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 1 WHERE id = ?", dtId);
|
||
continue;
|
||
}
|
||
Object errcodeMj = resultMap.get("errcode");
|
||
if (errcodeMj == null || errcodeMj == "" || new BigDecimal(errcodeMj.toString()).compareTo(BigDecimal.ZERO) != 0) {
|
||
baseBean.writeLog("pushMesToQw A failed:" + resultMap);
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 1 WHERE id = ?", dtId);
|
||
continue;
|
||
}
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 0 WHERE id = ?", dtId);
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("pushMesToQw A dt error:" + e);
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 1, yc = ? WHERE id = ?", e.getMessage(), dtId);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("pushMesToQw A error:" + e);
|
||
rs.executeUpdate("UPDATE uf_xxtsjlglb SET jg = 1, yc = ? WHERE id = ?", e.getMessage(), dataId);
|
||
}
|
||
baseBean.writeLog("pushMesToQw A end.");
|
||
}
|
||
|
||
public void getMiddleTableData(String ksrq, String jsrq, Map<String, String> ghAndIdMap, Set<String> signSet) {
|
||
BaseBean baseBean = new BaseBean();
|
||
baseBean.writeLog("getMiddleTableData start:" + ksrq + "、" + jsrq);
|
||
RecordSet rs = new RecordSet();
|
||
try {
|
||
Set<String> needFormatSet = new HashSet<>();
|
||
List<List> insertList = new ArrayList<>();
|
||
// Map<String, String> mesMap = new HashMap<>();
|
||
rs.executeSqlWithDataSource("SELECT * FROM timer_card WHERE card_date >= '" + ksrq + "' AND card_date <= '" + jsrq + "'", "\n" +
|
||
"nw_timer");
|
||
while (rs.next()) {
|
||
String cardWork = rs.getString("card_work");
|
||
String cardTime = rs.getString("card_time");
|
||
String cardAddr = rs.getString("card_addr");
|
||
String cardName = rs.getString("card_name");
|
||
if (StringUtils.isEmpty(cardWork) || StringUtils.isEmpty(cardTime) || StringUtils.isEmpty(cardAddr) || StringUtils.isEmpty(cardName)) {
|
||
continue;
|
||
}
|
||
String yg = ghAndIdMap.get(cardWork);
|
||
if (StringUtils.isEmpty(yg)) {
|
||
continue;
|
||
}
|
||
String[] s = cardTime.split(" ");
|
||
String rq = s[0];
|
||
String sj = s[1];
|
||
String keyTemp = yg + "_" + rq + "_" + sj;
|
||
if ((!CollectionUtils.isEmpty(signSet)) && signSet.contains(keyTemp)) {
|
||
continue;
|
||
}
|
||
List list = new ArrayList();
|
||
list.add(yg);
|
||
list.add("1");
|
||
list.add(rq);
|
||
list.add(sj);
|
||
list.add("1");
|
||
list.add(cardAddr);
|
||
list.add(rq);
|
||
insertList.add(list);
|
||
needFormatSet.add(yg + "_" + rq);
|
||
// mesMap.put(cardWork + "_" + rq + "_" + sj + "_" + cardName, cardAddr);
|
||
}
|
||
|
||
if (!CollectionUtils.isEmpty(insertList)) {
|
||
String insertSql = "INSERT INTO HrmScheduleSign(userId, userType, signDate, signTime, isInCom, " +
|
||
"signFrom, belongdate) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||
rs.executeBatchSql(insertSql, insertList);
|
||
}
|
||
|
||
// if (!CollectionUtils.isEmpty(mesMap)) {
|
||
// // 消息推送
|
||
// pushMesToQw(mesMap);
|
||
// }
|
||
|
||
if (!CollectionUtils.isEmpty(needFormatSet)) {
|
||
for (String key : needFormatSet) {
|
||
String yg = key.split("_")[0];
|
||
String rq = key.split("_")[1];
|
||
new KQFormatBiz().formatDate(yg, rq);
|
||
SplitActionUtil.pushOverTimeTasksAll(rq, rq, "" + yg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("getMiddleTableData error:" + e);
|
||
}
|
||
baseBean.writeLog("getMiddleTableData end.");
|
||
}
|
||
|
||
public String doPost(String url, Map<String, Object> paramMap, Map<String, String> headers) {
|
||
Assert.hasText(url, "Url is empty!");
|
||
CloseableHttpClient httpClient = null;
|
||
try {
|
||
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
|
||
SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(),
|
||
NoopHostnameVerifier.INSTANCE);
|
||
httpClient = HttpClients.custom().setSSLSocketFactory(scsf).build();
|
||
HttpPost httpPost = new HttpPost(url);
|
||
Gson gson = new Gson();
|
||
if (MapUtils.isNotEmpty(paramMap)) {
|
||
StringEntity entity = new StringEntity(gson.toJson(paramMap), "UTF-8");
|
||
entity.setContentEncoding("UTF-8");
|
||
entity.setContentType("application/json");
|
||
httpPost.setEntity(entity);
|
||
}
|
||
if (MapUtils.isNotEmpty(headers)) {
|
||
for (String key : headers.keySet()) {
|
||
httpPost.addHeader(key, headers.get(key));
|
||
}
|
||
}
|
||
|
||
HttpResponse response = httpClient.execute(httpPost);
|
||
String result;
|
||
result = getString(response);
|
||
|
||
return result;
|
||
} catch (Exception e) {
|
||
throw new RuntimeException("Exception occurred when send post request[url:" + url + "]!" + e.getMessage());
|
||
} finally {
|
||
if (httpClient != null) {
|
||
try {
|
||
httpClient.close();
|
||
} catch (IOException e) {
|
||
throw new RuntimeException("Exception occurred when httpClient:" + e.getMessage());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public String getString(HttpResponse response) throws IOException {
|
||
String result = null;
|
||
if (response != null) {
|
||
HttpEntity resEntity = response.getEntity();
|
||
if (resEntity != null) {
|
||
result = EntityUtils.toString(resEntity, "utf-8");
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
public void handleCountOption(String sjh) {
|
||
BaseBean baseBean = new BaseBean();
|
||
baseBean.writeLog("handleCountOption start:" + sjh);
|
||
try {
|
||
Thread.sleep(2000);
|
||
RecordSet rs = new RecordSet();
|
||
int dxzs = 0;
|
||
int ixzs = 0;
|
||
int sxzs = 0;
|
||
int cxzs = 0;
|
||
String dataId = null;
|
||
|
||
rs.executeQuery("SELECT * FROM uf_xgcs WHERE sjh = ?", sjh);
|
||
if (rs.next()) {
|
||
dataId = rs.getString("id");
|
||
String gyrsgwdnxqss = rs.getString("gyrsgwdnxqss");
|
||
if (StringUtils.equals(gyrsgwdnxqss, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(gyrsgwdnxqss, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(gyrsgwdnxqss, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(gyrsgwdnxqss, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String rgpslyddszkxzxshldlxwzkn = rs.getString("rgpslyddszkxzxshldlxwzkn");
|
||
if (StringUtils.equals(rgpslyddszkxzxshldlxwzkn, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(rgpslyddszkxzxshldlxwzkn, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(rgpslyddszkxzxshldlxwzkn, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(rgpslyddszkxzxshldlxwzkn, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String shswgkz = rs.getString("shswgkz");
|
||
if (StringUtils.equals(shswgkz, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(shswgkz, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(shswgkz, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(shswgkz, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String zddsshwdnxgxy = rs.getString("zddsshwdnxgxy");
|
||
if (StringUtils.equals(zddsshwdnxgxy, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(zddsshwdnxgxy, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(zddsshwdnxgxy, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(zddsshwdnxgxy, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String wrwzjzqgsdjbtds = rs.getString("wrwzjzqgsdjbtds");
|
||
if (StringUtils.equals(wrwzjzqgsdjbtds, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzqgsdjbtds, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzqgsdjbtds, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzqgsdjbtds, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
String wrwzjclgzwzkzysmw = rs.getString("wrwzjclgzwzkzysmw");
|
||
if (StringUtils.equals(wrwzjclgzwzkzysmw, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(wrwzjclgzwzkzysmw, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjclgzwzkzysmw, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjclgzwzkzysmw, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
String dyqrjwswzxwdf = rs.getString("dyqrjwswzxwdf");
|
||
if (StringUtils.equals(dyqrjwswzxwdf, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(dyqrjwswzxwdf, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(dyqrjwswzxwdf, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(dyqrjwswzxwdf, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
String zrjjwsw = rs.getString("zrjjwsw");
|
||
if (StringUtils.equals(zrjjwsw, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(zrjjwsw, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(zrjjwsw, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(zrjjwsw, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String wzsqjc = rs.getString("wzsqjc");
|
||
if (StringUtils.equals(wzsqjc, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(wzsqjc, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wzsqjc, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wzsqjc, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String tcwwcrwdfss = rs.getString("tcwwcrwdfss");
|
||
if (StringUtils.equals(tcwwcrwdfss, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(tcwwcrwdfss, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(tcwwcrwdfss, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(tcwwcrwdfss, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String rgyrssrnwsw = rs.getString("rgyrssrnwsw");
|
||
if (StringUtils.equals(rgyrssrnwsw, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(rgyrssrnwsw, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(rgyrssrnwsw, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(rgyrssrnwsw, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String zrjgxzwzzyds = rs.getString("zrjgxzwzzyds");
|
||
if (StringUtils.equals(zrjgxzwzzyds, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(zrjgxzwzzyds, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(zrjgxzwzzyds, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(zrjgxzwzzyds, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String zgzswbxclgdds = rs.getString("zgzswbxclgdds");
|
||
if (StringUtils.equals(zgzswbxclgdds, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(zgzswbxclgdds, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(zgzswbxclgdds, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(zgzswbxclgdds, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String wgwdlszykndwdpjs = rs.getString("wgwdlszykndwdpjs");
|
||
if (StringUtils.equals(wgwdlszykndwdpjs, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(wgwdlszykndwdpjs, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wgwdlszykndwdpjs, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wgwdlszykndwdpjs, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String pydwdpjzyknds = rs.getString("pydwdpjzyknds");
|
||
if (StringUtils.equals(pydwdpjzyknds, "0")) {
|
||
ixzs = ixzs + 1;
|
||
} else if (StringUtils.equals(pydwdpjzyknds, "1")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(pydwdpjzyknds, "2")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(pydwdpjzyknds, "3")) {
|
||
sxzs = sxzs + 1;
|
||
}
|
||
|
||
String zbztrdwtswnxdxfs = rs.getString("zbztrdwtswnxdxfs");
|
||
if (StringUtils.equals(zbztrdwtswnxdxfs, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(zbztrdwtswnxdxfs, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(zbztrdwtswnxdxfs, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(zbztrdwtswnxdxfs, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String mdtrdzjdzmwnx = rs.getString("mdtrdzjdzmwnx");
|
||
if (StringUtils.equals(mdtrdzjdzmwnx, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdzjdzmwnx, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdzjdzmwnx, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdzjdzmwnx, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String mdshwgx = rs.getString("mdshwgx");
|
||
if (StringUtils.equals(mdshwgx, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(mdshwgx, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(mdshwgx, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(mdshwgx, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String dygzwnxdtds = rs.getString("dygzwnxdtds");
|
||
if (StringUtils.equals(dygzwnxdtds, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(dygzwnxdtds, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(dygzwnxdtds, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(dygzwnxdtds, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String wrwzjzxwsdjbtds = rs.getString("wrwzjzxwsdjbtds");
|
||
if (StringUtils.equals(wrwzjzxwsdjbtds, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzxwsdjbtds, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzxwsdjbtds, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wrwzjzxwsdjbtds, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String dwzcsswqxy = rs.getString("dwzcsswqxy");
|
||
if (StringUtils.equals(dwzcsswqxy, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(dwzcsswqxy, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(dwzcsswqxy, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(dwzcsswqxy, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String djsydkgmxdgqswh = rs.getString("djsydkgmxdgqswh");
|
||
if (StringUtils.equals(djsydkgmxdgqswh, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(djsydkgmxdgqswh, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(djsydkgmxdgqswh, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(djsydkgmxdgqswh, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String mdtrdqswhgzjddshbnsqxy = rs.getString("mdtrdqswhgzjddshbnsqxy");
|
||
if (StringUtils.equals(mdtrdqswhgzjddshbnsqxy, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdqswhgzjddshbnsqxy, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdqswhgzjddshbnsqxy, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(mdtrdqswhgzjddshbnsqxy, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String wzyxngqtzjljgmz = rs.getString("wzyxngqtzjljgmz");
|
||
if (StringUtils.equals(wzyxngqtzjljgmz, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(wzyxngqtzjljgmz, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wzyxngqtzjljgmz, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wzyxngqtzjljgmz, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String znxdzsxflwjdgz = rs.getString("znxdzsxflwjdgz");
|
||
if (StringUtils.equals(znxdzsxflwjdgz, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(znxdzsxflwjdgz, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(znxdzsxflwjdgz, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(znxdzsxflwjdgz, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String rgwsldwnxgxwzbzxmzws = rs.getString("rgwsldwnxgxwzbzxmzws");
|
||
if (StringUtils.equals(rgwsldwnxgxwzbzxmzws, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(rgwsldwnxgxwzbzxmzws, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(rgwsldwnxgxwzbzxmzws, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(rgwsldwnxgxwzbzxmzws, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String wdrtdxqs = rs.getString("wdrtdxqs");
|
||
if (StringUtils.equals(wdrtdxqs, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(wdrtdxqs, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(wdrtdxqs, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(wdrtdxqs, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String dwhsghzdshw = rs.getString("dwhsghzdshw");
|
||
if (StringUtils.equals(dwhsghzdshw, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(dwhsghzdshw, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(dwhsghzdshw, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(dwhsghzdshw, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String rgwsfmwyxs = rs.getString("rgwsfmwyxs");
|
||
if (StringUtils.equals(rgwsfmwyxs, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(rgwsfmwyxs, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(rgwsfmwyxs, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(rgwsfmwyxs, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
|
||
String yxyszgynzlztszfhwdgj = rs.getString("yxyszgynzlztszfhwdgj");
|
||
if (StringUtils.equals(yxyszgynzlztszfhwdgj, "0")) {
|
||
sxzs = sxzs + 1;
|
||
} else if (StringUtils.equals(yxyszgynzlztszfhwdgj, "1")) {
|
||
dxzs = dxzs + 1;
|
||
} else if (StringUtils.equals(yxyszgynzlztszfhwdgj, "2")) {
|
||
cxzs = cxzs + 1;
|
||
} else if (StringUtils.equals(yxyszgynzlztszfhwdgj, "3")) {
|
||
ixzs = ixzs + 1;
|
||
}
|
||
}
|
||
|
||
baseBean.writeLog("handleCountOption update param:" + dxzs + "、" + ixzs + "、" + sxzs + "、" + cxzs + "、" + dataId);
|
||
|
||
if (StringUtils.isNotEmpty(dataId)) {
|
||
// 先将这个id回写到面试表
|
||
rs.executeUpdate("UPDATE uf_jcl_ms SET xgcssjid = ? WHERE mshj = 0 AND sjhm = ?", dataId, sjh);
|
||
rs.executeUpdate("UPDATE uf_xgcs SET dxzs = ?, ixzs = ?, sxzs = ?, cxzs = ? WHERE id = ?", dxzs, ixzs, sxzs, cxzs, dataId);
|
||
}
|
||
} catch (Exception e) {
|
||
baseBean.writeLog("handleCountOption error:" + e);
|
||
}
|
||
baseBean.writeLog("handleCountOption end.");
|
||
}
|
||
|
||
|
||
/**
|
||
* 更新笔试结果
|
||
*
|
||
* @param sheetAt
|
||
* @param lastRowNum
|
||
* @param idCellNum
|
||
* @param scoreCellNum
|
||
* @param resultCellNum
|
||
* @return
|
||
*/
|
||
private Map<String, Object> updateWrittenResult(XSSFSheet sheetAt, int lastRowNum, Integer idCellNum, Integer scoreCellNum, Integer resultCellNum) {
|
||
Map<String, Object> resultMap = new HashMap<>(4);
|
||
Integer allCount = 0;
|
||
Integer successCount = 0;
|
||
Integer failCount = 0;
|
||
List<ImportLog> logList = new ArrayList<>();
|
||
RecordSet rs = new RecordSet();
|
||
for (int rowIndex = 1; rowIndex <= lastRowNum; rowIndex++) {
|
||
allCount++;
|
||
XSSFRow row = sheetAt.getRow(rowIndex);
|
||
if (null == row) {
|
||
continue;
|
||
}
|
||
List<String> descriptionList = new ArrayList<>();
|
||
boolean success = true;
|
||
XSSFCell idCell = row.getCell(idCellNum);
|
||
String ideCellValue = ExcelUtil.getCellValue(idCell).trim();
|
||
if (StringUtils.isBlank(ideCellValue)) {
|
||
descriptionList.add("[ID]为空");
|
||
success = false;
|
||
}
|
||
XSSFCell scoreCell = row.getCell(scoreCellNum);
|
||
String scoreCellValue = ExcelUtil.getCellValue(scoreCell).trim();
|
||
if (StringUtils.isBlank(scoreCellValue)) {
|
||
descriptionList.add("[笔试成绩]为空");
|
||
success = false;
|
||
}
|
||
XSSFCell resultCell = row.getCell(resultCellNum);
|
||
String resultCellValue = ExcelUtil.getCellValue(resultCell).trim();
|
||
if (StringUtils.isBlank(resultCellValue)) {
|
||
descriptionList.add("[笔试结果]为空");
|
||
success = false;
|
||
}
|
||
if (StringUtils.isNotBlank(resultCellValue)) {
|
||
resultCellValue = convertResultValue(resultCellValue);
|
||
if (StringUtils.isBlank(resultCellValue)) {
|
||
descriptionList.add("[笔试结果]转换失败");
|
||
success = false;
|
||
}
|
||
}
|
||
|
||
// 更新笔试成绩
|
||
if (success) {
|
||
rs.executeUpdate("update uf_jcl_bs set bscj = ? ,bsjg = ? where id = ? ", scoreCellValue, resultCellValue, ideCellValue);
|
||
String exceptionMsg = rs.getExceptionMsg();
|
||
if (StringUtils.isNotBlank(exceptionMsg)) {
|
||
descriptionList.add(exceptionMsg);
|
||
success = false;
|
||
}
|
||
}
|
||
if (success) {
|
||
successCount++;
|
||
} else {
|
||
failCount++;
|
||
}
|
||
|
||
ImportLog importLog = ImportLog.builder().
|
||
rowIndex(rowIndex + 1) // 对应Excel的行,从1开始累加
|
||
.description(success ? "导入成功" : StringUtils.join(descriptionList, ","))
|
||
.status(String.valueOf(success))
|
||
.build();
|
||
logList.add(importLog);
|
||
}
|
||
resultMap.put("log", logList);
|
||
resultMap.put("allCount", allCount);
|
||
resultMap.put("successCount", successCount);
|
||
resultMap.put("failCount", failCount);
|
||
return resultMap;
|
||
}
|
||
|
||
|
||
/**
|
||
* 标题行、校验必填列
|
||
*
|
||
* @param keyMap 字段集合
|
||
* @param requiredFields 必填字段
|
||
*/
|
||
private void checkRequiredFields(Map<String, Integer> keyMap, String... requiredFields) {
|
||
// 校验必填列
|
||
Set<String> keySet = keyMap.keySet();
|
||
for (String field : requiredFields) {
|
||
if (!keySet.contains(field)) {
|
||
throw new CustomizeRunTimeException("未获取到必填列[" + field + "]");
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 转化笔试结果的值
|
||
*
|
||
* @param resultCellValue
|
||
* @return
|
||
*/
|
||
private String convertResultValue(String resultCellValue) {
|
||
int formId = ApplicantCommonInfo.getFormIdByTableName("uf_jcl_bs");
|
||
return ApplicantCommonInfo.getSelectValue(String.valueOf(formId), "bsjg", resultCellValue);
|
||
}
|
||
}
|