|
|
package com.engine.kr.service.impl;
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.engine.core.impl.Service;
|
|
|
import com.engine.kr.entity.kq.KqGlobal;
|
|
|
import com.engine.kr.enums.KqInteractiveEnum;
|
|
|
import com.engine.kr.exception.CustomizeRunTimeException;
|
|
|
import com.engine.kr.service.KqInteractiveService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
import weaver.conn.RecordSet;
|
|
|
import weaver.file.ImageFileManager;
|
|
|
import weaver.general.BaseBean;
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.Base64;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author:dxfeng
|
|
|
* @createTime: 2023/05/17
|
|
|
* @version: 1.0
|
|
|
*/
|
|
|
public class KqInteractiveServiceImpl extends Service implements KqInteractiveService {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getLeaveBal(Map<String, Object> params) {
|
|
|
String token = getToken();
|
|
|
|
|
|
String jqlx = Util.null2String(params.get("jqlx"));
|
|
|
String resourceId = Util.null2String(params.get("resourceId"));
|
|
|
String dayoffType = "";
|
|
|
String workCode = "";
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("select kqxtzdz from uf_jqzdpp where lczd =?", jqlx);
|
|
|
|
|
|
if (rs.next()) {
|
|
|
dayoffType = rs.getString("kqxtzdz");
|
|
|
}
|
|
|
if (StringUtils.isBlank(dayoffType)) {
|
|
|
throw new RuntimeException("假期余额获取失败,未找到假期类型对应编码[" + jqlx + "]");
|
|
|
}
|
|
|
rs.executeQuery("select workcode from hrmresource where id = ?", resourceId);
|
|
|
if (rs.next()) {
|
|
|
workCode = rs.getString("workcode");
|
|
|
}
|
|
|
if (StringUtils.isBlank(workCode)) {
|
|
|
workCode = Util.null2String(params.get("workCode"));
|
|
|
}
|
|
|
|
|
|
|
|
|
Map<String, Object> postParam = new HashMap<>(4);
|
|
|
postParam.put("token", token);
|
|
|
postParam.put("personId", workCode);
|
|
|
// 假别转换为代码
|
|
|
postParam.put("dayoffType", dayoffType);
|
|
|
// 可不填
|
|
|
postParam.put("leaveDate", params.get("ksrq"));
|
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
String returnStr = HttpUtil.post(KqGlobal.POST_URL + KqInteractiveEnum.LEAVE_BAL.getPostPath(), postParam);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(returnStr);
|
|
|
String code = jsonObject.getString("code");
|
|
|
|
|
|
if (KqGlobal.SUC_CODE.equals(code)) {
|
|
|
returnMap.put("dayoffBalHours", jsonObject.getString("dayoffBalHours"));
|
|
|
} else {
|
|
|
throw new CustomizeRunTimeException("假期余额获取失败," + jsonObject.getString("msg"));
|
|
|
}
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getUserImage(Map<String, Object> params) {
|
|
|
Map<String, Object> returnMap = new HashMap<>(3);
|
|
|
String personId = Util.null2String(params.get("personId"));
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("select resourceimageid from hrmresource where workcode = ? ", personId);
|
|
|
String resourceImageId = "";
|
|
|
if (rs.next()) {
|
|
|
resourceImageId = rs.getString("resourceimageid");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(resourceImageId)) {
|
|
|
ImageFileManager manager = new ImageFileManager();
|
|
|
manager.getImageFileInfoById(Util.getIntValue(resourceImageId));
|
|
|
InputStream inputStream = manager.getInputStream();
|
|
|
try {
|
|
|
returnMap.put("base64", Base64.getEncoder().encodeToString(IOUtils.toByteArray(inputStream)));
|
|
|
returnMap.put("filetype", manager.getImageFileType());
|
|
|
returnMap.put("fileName", manager.getImageFileName());
|
|
|
} catch (IOException e) {
|
|
|
new BaseBean().writeLog(e);
|
|
|
throw new CustomizeRunTimeException(e.getMessage());
|
|
|
}
|
|
|
} else {
|
|
|
throw new CustomizeRunTimeException("文件获取失败");
|
|
|
}
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 请求,获取token
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public String getToken() {
|
|
|
Map<String, Object> params = new HashMap<>(2);
|
|
|
params.put("user", KqGlobal.USER);
|
|
|
params.put("pass", KqGlobal.PASS);
|
|
|
String returnStr = HttpUtil.post(KqGlobal.POST_URL + KqInteractiveEnum.TOKEN.getPostPath(), params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(returnStr);
|
|
|
String code = jsonObject.getString("code");
|
|
|
if (KqGlobal.SUC_CODE.equals(code)) {
|
|
|
return jsonObject.getString("token");
|
|
|
} else {
|
|
|
throw new CustomizeRunTimeException("token获取失败," + jsonObject.getString("msg"));
|
|
|
}
|
|
|
}
|
|
|
}
|