茶百道代码备份
This commit is contained in:
parent
27d803ed02
commit
95d26b89df
|
|
@ -0,0 +1,9 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1167276462243069953";
|
||||
|
||||
public static String templatePath = "/nfs/data/weatempfiles/downloadtemp";
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.constant;
|
||||
|
||||
|
||||
public enum DownLoadTypeEnum {
|
||||
|
||||
INFORMATION("0","info", "info","签署文件下载","附件管理"),
|
||||
CONTRACT("1","contract", "contract","签署文件下载","人事合同"),
|
||||
INCOME("2","income", "income","签署文件下载","收入证明"),
|
||||
EMPLOYMENT("3","employment", "employment","签署文件下载","在职证明"),
|
||||
RESIGN("4","resign", "resign","签署文件下载","离职证明");
|
||||
|
||||
private String code;
|
||||
private String type;
|
||||
|
||||
private String path;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String description;
|
||||
|
||||
private DownLoadTypeEnum(String code,String type, String path,String fileName,String description) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.path = path;
|
||||
this.fileName = fileName;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.DownLoadTypeEnum;
|
||||
import com.weaver.seconddev.chapanda.hrm.service.HrmDownloadFilesService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/chapanda/hrm/cert")
|
||||
public class HrmCertificateFilesController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(HrmCertificateFilesController.class);
|
||||
|
||||
@Autowired
|
||||
HrmDownloadFilesService hrmDownloadFilesService;
|
||||
|
||||
/***
|
||||
*
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/getincomepath")
|
||||
public WeaResult<Object> getIncomePath(@RequestBody Map<String,Object> paramMap){
|
||||
String data = String.valueOf(paramMap.get("data"));
|
||||
log.error("data:{}",data);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
String decodedData = hrmDownloadFilesService.convertBase64Data(data);
|
||||
log.error("decodedData:{}",decodedData);
|
||||
if(StringUtils.isNotBlank(decodedData)){
|
||||
try{
|
||||
dataArray = JSONArray.parseArray(decodedData);
|
||||
}catch (Exception e){
|
||||
log.error("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("dataArray:{}",dataArray.size());
|
||||
|
||||
String newZipFilePath = hrmDownloadFilesService.convertZipFile(dataArray, DownLoadTypeEnum.INCOME.getPath());
|
||||
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
dataMap.put("filepath",newZipFilePath);
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 离职证明下载接口
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/getresignpath")
|
||||
public WeaResult<Object> getResignPath(@RequestBody Map<String,Object> paramMap){
|
||||
String data = String.valueOf(paramMap.get("data"));
|
||||
log.error("data:{}",data);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
String decodedData = hrmDownloadFilesService.convertBase64Data(data);
|
||||
log.error("decodedData:{}",decodedData);
|
||||
if(StringUtils.isNotBlank(decodedData)){
|
||||
try{
|
||||
dataArray = JSONArray.parseArray(decodedData);
|
||||
}catch (Exception e){
|
||||
log.error("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("dataArray:{}",dataArray.size());
|
||||
|
||||
String newZipFilePath = hrmDownloadFilesService.convertZipFile(dataArray, DownLoadTypeEnum.RESIGN.getPath());
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
dataMap.put("filepath",newZipFilePath);
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 在职证明下载接口
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/getemploymentpath")
|
||||
public WeaResult<Object> getEmploymentPath(@RequestBody Map<String,Object> paramMap){
|
||||
String data = String.valueOf(paramMap.get("data"));
|
||||
log.error("data:{}",data);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
String decodedData = hrmDownloadFilesService.convertBase64Data(data);
|
||||
if(StringUtils.isNotBlank(decodedData)){
|
||||
try{
|
||||
dataArray = JSONArray.parseArray(decodedData);
|
||||
}catch (Exception e){
|
||||
log.error("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("dataArray:{}",dataArray.size());
|
||||
|
||||
String newZipFilePath = hrmDownloadFilesService.convertZipFile(dataArray,DownLoadTypeEnum.EMPLOYMENT.getPath());
|
||||
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
dataMap.put("filepath",newZipFilePath);
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/getcontractpath")
|
||||
public WeaResult<Object> getContractPath(@RequestBody Map<String,Object> paramMap){
|
||||
String data = String.valueOf(paramMap.get("data"));
|
||||
log.error("data:{}",data);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
String decodedData = hrmDownloadFilesService.convertBase64Data(data);
|
||||
if(StringUtils.isNotBlank(decodedData)){
|
||||
try{
|
||||
dataArray = JSONArray.parseArray(decodedData);
|
||||
}catch (Exception e){
|
||||
log.error("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("dataArray:{}",dataArray.size());
|
||||
|
||||
String newZipFilePath = hrmDownloadFilesService.convertZipFile(dataArray, DownLoadTypeEnum.CONTRACT.getPath());
|
||||
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
dataMap.put("filepath",newZipFilePath);
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
/***
|
||||
* 电子签名模板预览接口
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/downloadZip")
|
||||
public ResponseEntity downloadZip(HttpServletRequest request) throws IOException{
|
||||
String data = request.getParameter("data");
|
||||
String type = request.getParameter("type");
|
||||
log.error("data2:{}",data);
|
||||
log.error("typ2e:{}",type);
|
||||
String filename = "";
|
||||
try{
|
||||
DownLoadTypeEnum[] values = DownLoadTypeEnum.values();
|
||||
for (DownLoadTypeEnum item : values) {
|
||||
log.error("item.getCode():{}",item.getCode());
|
||||
if(item.getCode().equals(type)){
|
||||
filename = DownLoadTypeEnum.INCOME.getFileName();
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(filename)){
|
||||
filename = URLEncoder.encode(filename, "UTF-8"); // 使用UTF-8编码
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
|
||||
log.error("filename2:{}",filename);
|
||||
|
||||
if(StringUtils.isNotBlank(filename)){
|
||||
log.error("data:{}",data);
|
||||
String zipFilePath = "";
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
zipFilePath = hrmDownloadFilesService.convertBase64Data(data);
|
||||
}
|
||||
log.error("zipFilePath:{}",zipFilePath);
|
||||
if(StringUtils.isNotBlank(zipFilePath) && zipFilePath.contains(Constants.templatePath) && new File(zipFilePath).exists()){
|
||||
// 文件转成字节数组
|
||||
File file = ResourceUtils.getFile(zipFilePath);
|
||||
byte[] fileBytes = Files.readAllBytes(file.toPath());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String filename2 = filename+"-"+sdf.format(new Date())+".zip";
|
||||
log.error("filename2:{}",filename2);
|
||||
|
||||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + new String(filename2.getBytes(), "UTF-8") + "\"")
|
||||
.body(fileBytes);
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new String("文件下载失败".getBytes(), "utf-8"));
|
||||
}
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new String("文件下载失败".getBytes(), "utf-8"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,328 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.eteams.file.client.file.FileData;
|
||||
import com.weaver.eteams.file.client.file.FileObj;
|
||||
import com.weaver.file.ud.api.FileDownloadService;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.DownLoadTypeEnum;
|
||||
import com.weaver.seconddev.chapanda.hrm.service.HrmDownloadFilesService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import java.util.Base64;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/chapanda/hrm/info")
|
||||
public class HrmInformationFilesController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(HrmInformationFilesController.class);
|
||||
|
||||
@Autowired
|
||||
private FileDownloadService fileDownloadService;
|
||||
|
||||
@Autowired
|
||||
HrmDownloadFilesService hrmDownloadFilesService;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/getinformationpath")
|
||||
public WeaResult<Object> getInformationPath(@RequestBody Map<String,Object> paramMap){
|
||||
String data = String.valueOf(paramMap.get("data"));
|
||||
log.error("data:{}",data);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
String decodedData = hrmDownloadFilesService.convertBase64Data(data);
|
||||
log.error("decodedData:{}",decodedData);
|
||||
if(StringUtils.isNotBlank(decodedData)){
|
||||
try{
|
||||
dataArray = JSONArray.parseArray(decodedData);
|
||||
}catch (Exception e){
|
||||
log.error("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("dataArray:{}",dataArray.size());
|
||||
|
||||
String newZipFilePath = convertZipFile(dataArray, DownLoadTypeEnum.INFORMATION.getCode());
|
||||
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
// String filename = sdf.format(new Date())+".zip";
|
||||
//
|
||||
// String directoryPath = Constants.templatePath+File.separator+sdf.format(new Date());
|
||||
// // 将字符串路径转换为Path对象
|
||||
// Path path = Paths.get(directoryPath);
|
||||
// // 检查目录是否存在
|
||||
// if (Files.notExists(path)) {
|
||||
// try {
|
||||
// Files.createDirectories(path);
|
||||
// } catch (IOException e) {
|
||||
// log.error("e:{}",e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String zipFilePath = directoryPath+File.separator+filename;
|
||||
// try {
|
||||
// log.error("path:{}",zipFilePath);
|
||||
// FileOutputStream fos = new FileOutputStream(zipFilePath);
|
||||
// ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
// for(int i=0;i<dataArray.size();i++){
|
||||
// JSONObject dataObject = dataArray.getJSONObject(i);
|
||||
// String jobNum = dataObject.getString("jobnum");
|
||||
// String userName = dataObject.getString("username");
|
||||
// String fileId = dataObject.getString("fileid");
|
||||
//
|
||||
// log.error("fileId:{}",fileId);
|
||||
// log.error("userName:{}",userName);
|
||||
// log.error("jobNum:{}",jobNum);
|
||||
//
|
||||
// if(StringUtils.isNotBlank(fileId)){
|
||||
// try {
|
||||
// FileData fileData = fileDownloadService.downloadFile(Long.parseLong(fileId));
|
||||
// FileObj fileObj = fileData.getFileObj();
|
||||
// // 获取文件的输入流
|
||||
// InputStream inputStream = fileData.getInputStream();
|
||||
// log.error("inputStream:{}",inputStream.available());
|
||||
// String fileName = fileObj.getName();
|
||||
// log.error("fileName:{}",fileName);
|
||||
// byte[] filedata = hrmDownloadFilesService.convertInputStreamToBytes(inputStream);
|
||||
//
|
||||
// addFileToZip(zos, filedata, fileName,jobNum,userName);
|
||||
// } catch (IOException e) {
|
||||
// log.error("e:" , e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// zos.close();
|
||||
// fos.close();
|
||||
// }catch (IOException e){
|
||||
// log.error("e:{}",e);
|
||||
// }
|
||||
|
||||
// String newZipFilePath = "";
|
||||
// File zipFile = new File(zipFilePath);
|
||||
// if(zipFile.exists()){
|
||||
// newZipFilePath = zipFile.getPath();
|
||||
// }
|
||||
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
dataMap.put("filepath",newZipFilePath);
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 转换为zip文件
|
||||
* @param dataArray
|
||||
* @param downloadType
|
||||
* @return
|
||||
*/
|
||||
public String convertZipFile(JSONArray dataArray,String downloadType) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String filename = sdf.format(new Date())+".zip";
|
||||
|
||||
String directoryPath = Constants.templatePath+ File.separator+downloadType+File.separator+sdf.format(new Date());
|
||||
// 将字符串路径转换为Path对象
|
||||
Path path = Paths.get(directoryPath);
|
||||
// 检查目录是否存在
|
||||
if (Files.notExists(path)) {
|
||||
try {
|
||||
Files.createDirectories(path);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
String zipFilePath = directoryPath+File.separator+filename;
|
||||
FileOutputStream fos = null;
|
||||
ZipOutputStream zos = null;
|
||||
try {
|
||||
log.error("path:{}",zipFilePath);
|
||||
fos = new FileOutputStream(zipFilePath);
|
||||
zos = new ZipOutputStream(fos);
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataObject = dataArray.getJSONObject(i);
|
||||
String jobNum = dataObject.getString("jobnum");
|
||||
String userName = dataObject.getString("username");
|
||||
String fileId = dataObject.getString("fileid");
|
||||
|
||||
log.error("fileId:{}",fileId);
|
||||
log.error("userName:{}",userName);
|
||||
log.error("jobNum:{}",jobNum);
|
||||
|
||||
if(StringUtils.isNotBlank(fileId)){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
FileData fileData = fileDownloadService.downloadFile(Long.parseLong(fileId));
|
||||
FileObj fileObj = fileData.getFileObj();
|
||||
// 获取文件的输入流
|
||||
inputStream = fileData.getInputStream();
|
||||
log.error("inputStream:{}",inputStream.available());
|
||||
String fileName = fileObj.getName();
|
||||
log.error("fileName:{}",fileName);
|
||||
byte[] filedata = hrmDownloadFilesService.convertInputStreamToBytes(inputStream);
|
||||
|
||||
addFileToZip(zos, filedata, fileName,jobNum,userName);
|
||||
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error("e:" , e);
|
||||
}finally {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zos.close();
|
||||
fos.close();
|
||||
}catch (IOException e){
|
||||
log.error("e:{}",e);
|
||||
}finally {
|
||||
try {
|
||||
if (zos != null) {
|
||||
zos.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String newZipFilePath = "";
|
||||
File zipFile = new File(zipFilePath);
|
||||
if(zipFile.exists()){
|
||||
newZipFilePath = zipFile.getPath();
|
||||
}
|
||||
return newZipFilePath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 电子签名模板预览接口
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/downloadZip")
|
||||
public ResponseEntity downloadZip(HttpServletRequest request) throws IOException{
|
||||
String data = request.getParameter("data");
|
||||
String type = request.getParameter("type");
|
||||
log.error("data2:{}",data);
|
||||
log.error("typ2e:{}",type);
|
||||
String filename = "";
|
||||
try{
|
||||
DownLoadTypeEnum[] values = DownLoadTypeEnum.values();
|
||||
for (DownLoadTypeEnum item : values) {
|
||||
log.error("item.getCode():{}",item.getCode());
|
||||
if(item.getCode().equals(type)){
|
||||
filename = DownLoadTypeEnum.INCOME.getFileName();
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(filename)){
|
||||
filename = URLEncoder.encode(filename, "UTF-8"); // 使用UTF-8编码
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
String zipFilePath = "";
|
||||
if(StringUtils.isNotBlank(data)){
|
||||
zipFilePath = hrmDownloadFilesService.convertBase64Data(data);
|
||||
}
|
||||
if(StringUtils.isNotBlank(filename)){
|
||||
log.error("zipFilePath:{}",zipFilePath);
|
||||
if(StringUtils.isNotBlank(zipFilePath) && zipFilePath.contains(Constants.templatePath) && new File(zipFilePath).exists()){
|
||||
// 文件转成字节数组
|
||||
File file = ResourceUtils.getFile(zipFilePath);
|
||||
byte[] fileBytes = Files.readAllBytes(file.toPath());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String filename2 = filename+"-"+sdf.format(new Date())+".zip";
|
||||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + new String(filename2.getBytes(), "UTF-8") + "\"")
|
||||
.body(fileBytes);
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new String("文件下载失败".getBytes(), "utf-8"));
|
||||
}
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new String("文件下载失败".getBytes(), "utf-8"));
|
||||
}
|
||||
}
|
||||
|
||||
// 将文件添加到zip输出流
|
||||
private void addFileToZip(ZipOutputStream zos, byte[] fileData, String entryName,String jobNum,String fileName) throws IOException {
|
||||
ZipEntry entry = new ZipEntry(fileName+"_"+jobNum+"/"+entryName);
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(fileData);
|
||||
zos.closeEntry();
|
||||
}
|
||||
/**
|
||||
* 测试接口
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String originalString = "/nfs/data/weatempfiles/downloadtemp/1111/1111.zip";
|
||||
|
||||
//
|
||||
// String originalString = "[{\"fielid\":\"1169600692452909062\",\"jobnum\":\"10000000000\",\"username\":\"王文猛\"},{\"fielid\":\"1169600688166330369\",\"jobnum\":\"10000000000\",\"username\":\"王文猛\"},{\"fielid\":\"1167396240209780739\",\"jobnum\":\"1000002229\",\"username\":\"崔晓龙\"},{\"fielid\":\"1167650515133440001\",\"jobnum\":\"1000002805\",\"username\":\"刘琪琪\"},{\"fielid\":\"1167395969819779075\",\"jobnum\":\"1000003958\",\"username\":\"刘颖慧\"},{\"fielid\":\"1169538849218813953\",\"jobnum\":\"1000003958\",\"username\":\"刘颖慧\"},{\"fielid\":\"1169601053305659394\",\"jobnum\":\"1000003958\",\"username\":\"刘颖慧\"},{\"fielid\":\"1169543698203336705\",\"jobnum\":\"1000003958\",\"username\":\"刘颖慧\"},{\"fielid\":\"1169501139481452545\",\"jobnum\":\"1000004336\",\"username\":\"蒋欢\"},{\"fielid\":\"1167403559018602499\",\"jobnum\":\"1000004410\",\"username\":\"刘贤松\"},{\"fielid\":\"1167394818600771585\",\"jobnum\":\"1000004846\",\"username\":\"刘刚菊\"},{\"fielid\":\"1167389900896772097\",\"jobnum\":\"1000006146\",\"username\":\"周娟\"},{\"fielid\":\"1169540279359037441\",\"jobnum\":\"1000006146\",\"username\":\"周娟\"},{\"fielid\":\"1167718573191520257\",\"jobnum\":\"1000006146\",\"username\":\"周娟\"}]";
|
||||
// 将字符串转换为字节数组
|
||||
byte[] bytesToEncode = originalString.getBytes();
|
||||
|
||||
// 创建Base64编码器
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
|
||||
// 编码字节数组
|
||||
String encodedString = encoder.encodeToString(bytesToEncode);
|
||||
|
||||
System.out.println("Encoded String: " + encodedString);
|
||||
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
|
||||
// 解码Base64字符串
|
||||
byte[] bytesDecoded = decoder.decode(encodedString);
|
||||
|
||||
// 将字节数组转换回字符串
|
||||
String decodedString = new String(bytesDecoded);
|
||||
|
||||
System.out.println("Decoded String: " + decodedString);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.*;
|
||||
import com.weaver.seconddev.chapanda.hrm.service.HrmTableFieldService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/chapanda/hrm/form")
|
||||
public class HrmTableFieldController {
|
||||
private final Logger log = LoggerFactory.getLogger(HrmTableFieldController.class);
|
||||
|
||||
@Autowired
|
||||
private HrmTableFieldService hrmTableFieldService;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/getdetailfield")
|
||||
public WeaResult<Object> getDetailField(HttpServletRequest request, HttpServletResponse response){
|
||||
String tablename = String.valueOf(request.getParameter("tablename"));
|
||||
log.error("tablename:{}",tablename);
|
||||
String detailname = String.valueOf(request.getParameter("detailname"));
|
||||
log.error("detailname:{}",detailname);
|
||||
List<Map<String,Object>> dataList = hrmTableFieldService.queryTableDetailFieldByTableName(tablename,detailname);
|
||||
return WeaResult.success(dataList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.hrm.util.DatabaseUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class HrmFormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmFormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
|
||||
/***
|
||||
* 获取eb表的appid和formid
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Eb表的字段信息
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取下拉框的名称
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String queryTableFormIdByTableName(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String form_id = "";
|
||||
try{
|
||||
String dataSql =" select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
form_id = String.valueOf(recordMap.get("form_id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return form_id;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,Object>> queryTableDetailFieldByTableName(String tableName,String detailName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
|
||||
// String dataSql =" select id,form_id,title,data_key\n" +
|
||||
// " from form_field\n" +
|
||||
// " where form_id in( select form_id from form_table where table_name='uf_xxbgcj' and delete_type=0 and tenant_key =?)\n" +
|
||||
// " and sub_form_id in(select id from sub_form where data_key='uf_jcl_empxxbg_work' and FORM_ID in(select form_id from form_table where table_name='uf_xxbgcj' and delete_type=0 and tenant_key=?) and delete_type=0 and tenant_key =? \n" +
|
||||
// " )\n" +
|
||||
// " and delete_type=0\n" +
|
||||
// " and tenant_key = ?" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key\n" +
|
||||
" from form_field\n" +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key =?)\n" +
|
||||
" and sub_form_id in(select id from sub_form where data_key=? and form_id in(select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?) and delete_type=0 and tenant_key =? \n" +
|
||||
" )\n" +
|
||||
" and delete_type=0\n" +
|
||||
" and tenant_key = ?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(detailName);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.InputStream;
|
||||
|
||||
@Component
|
||||
public interface HrmDownloadFilesService {
|
||||
|
||||
byte[] convertInputStreamToBytes(InputStream inputStream);
|
||||
|
||||
String convertBase64Data(String base64Data);
|
||||
|
||||
String convertZipFile(JSONArray dataArray, String downloadType);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface HrmTableFieldService {
|
||||
|
||||
List<Map<String,Object>> queryTableDetailFieldByTableName(String tableName,String detailName);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.eteams.file.client.file.FileData;
|
||||
import com.weaver.eteams.file.client.file.FileObj;
|
||||
import com.weaver.file.ud.api.FileDownloadService;
|
||||
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.hrm.service.HrmDownloadFilesService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class HrmDownloadFilesServiceImpl implements HrmDownloadFilesService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmDownloadFilesServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
HrmDownloadFilesService hrmDownloadFilesService;
|
||||
|
||||
@Autowired
|
||||
private FileDownloadService fileDownloadService;
|
||||
|
||||
/***
|
||||
* 将InputStream转换为byte[]
|
||||
* @param inputStream
|
||||
* @return
|
||||
*/
|
||||
public byte[] convertInputStreamToBytes(InputStream inputStream) {
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
try{
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
byteStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
log.error("byteStream:{}",byteStream.toByteArray().length);
|
||||
}catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
}
|
||||
return byteStream.toByteArray();
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param base64Data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String convertBase64Data(String base64Data) {
|
||||
String decodedData = "";
|
||||
try{
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
// 解码Base64字符串
|
||||
byte[] bytesDecoded = decoder.decode(base64Data);
|
||||
// 将字节数组转换回字符串
|
||||
decodedData = new String(bytesDecoded, StandardCharsets.UTF_8);
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return decodedData;
|
||||
}
|
||||
|
||||
|
||||
public String convertZipFile(JSONArray dataArray,String downloadType) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String filename = sdf.format(new Date())+".zip";
|
||||
|
||||
String directoryPath = Constants.templatePath+ File.separator+downloadType+File.separator+sdf.format(new Date());
|
||||
// 将字符串路径转换为Path对象
|
||||
Path path = Paths.get(directoryPath);
|
||||
// 检查目录是否存在
|
||||
if (Files.notExists(path)) {
|
||||
try {
|
||||
Files.createDirectories(path);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
String zipFilePath = directoryPath+File.separator+filename;
|
||||
FileOutputStream fos = null;
|
||||
ZipOutputStream zos = null;
|
||||
try {
|
||||
log.error("path:{}",zipFilePath);
|
||||
fos = new FileOutputStream(zipFilePath);
|
||||
zos = new ZipOutputStream(fos);
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataObject = dataArray.getJSONObject(i);
|
||||
String fileId = dataObject.getString("fileid");
|
||||
log.error("fileId:{}",fileId);
|
||||
if(StringUtils.isNotBlank(fileId)){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
FileData fileData = fileDownloadService.downloadFile(Long.parseLong(fileId));
|
||||
FileObj fileObj = fileData.getFileObj();
|
||||
// 获取文件的输入流
|
||||
inputStream = fileData.getInputStream();
|
||||
log.error("inputStream:{}",inputStream.available());
|
||||
String fileName = fileObj.getName();
|
||||
log.error("fileName:{}",fileName);
|
||||
byte[] filedata = hrmDownloadFilesService.convertInputStreamToBytes(inputStream);
|
||||
|
||||
addFileToZip(zos, filedata, fileName);
|
||||
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error("e:" , e);
|
||||
}finally {
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
zos.close();
|
||||
fos.close();
|
||||
}catch (IOException e){
|
||||
log.error("e:{}",e);
|
||||
}finally {
|
||||
try {
|
||||
if (zos != null) {
|
||||
zos.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
String newZipFilePath = "";
|
||||
File zipFile = new File(zipFilePath);
|
||||
if(zipFile.exists()){
|
||||
newZipFilePath = zipFile.getPath();
|
||||
}
|
||||
return newZipFilePath;
|
||||
}
|
||||
|
||||
// 将文件添加到zip输出流
|
||||
private void addFileToZip(ZipOutputStream zos, byte[] fileData, String entryName) throws IOException {
|
||||
// ZipEntry entry = new ZipEntry(fileName+"_"+jobNum+"/"+entryName);
|
||||
ZipEntry entry = new ZipEntry(entryName);
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(fileData);
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String data = "L25mcy9kYXRhL3dlYXRlbXBmaWxlcy9kb3dubG9hZHRlbXAvcmVzaWduLzIwMjUwODI2MTczNjU3L+emu+iBjOivgeaYji0yMDI1MDgyNjE3MzY1Ny56aXA=";
|
||||
HrmDownloadFilesServiceImpl HrmDownloadFilesServiceImpl = new HrmDownloadFilesServiceImpl();
|
||||
String decodedData = HrmDownloadFilesServiceImpl.convertBase64Data(data);
|
||||
System.out.println(decodedData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.service.impl;
|
||||
|
||||
import com.weaver.seconddev.chapanda.hrm.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.hrm.service.HrmTableFieldService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class HrmTableFieldServiceImpl implements HrmTableFieldService{
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
@Override
|
||||
public List<Map<String,Object>> queryTableDetailFieldByTableName(String tableName, String detailName) {
|
||||
List<Map<String,Object>> dataList = hrmFormFieldDao.queryTableDetailFieldByTableName(tableName,detailName);
|
||||
return dataList;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,430 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
public Long convertStringToLong(String str) {
|
||||
try {
|
||||
return Long.valueOf(str);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
package com.weaver.seconddev.chapanda.hrm.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.cache;
|
||||
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.common.cache.base.ModuleCacheInterface;
|
||||
import com.weaver.common.cache.base.exception.IllegalCacheAccessException;
|
||||
import com.weaver.seconddev.chapanda.beisen.module.BeisenTokenModuleKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 集成缓存类
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
@Component
|
||||
public class BeisenTokenCacheKey implements ModuleCacheInterface {
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
//科大accesstoken
|
||||
public final static String BEISEN_TOKEN = "BEISEN_TOKEN";
|
||||
|
||||
@Override
|
||||
public void register() throws IllegalCacheAccessException, IllegalAccessException {
|
||||
baseCache.register(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, this.getClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1167276462243069953";
|
||||
// public static String SysUserId = "1147262704872284161";
|
||||
|
||||
public static String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
public static String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
public static String tokenUrl = "https://openapi.italent.cn/token";
|
||||
|
||||
public static String beishenHost = "https://openapi.italent.cn";
|
||||
public static String createBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/Create";
|
||||
public static String deleteBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/BatchDelete";
|
||||
|
||||
public static String offerUrl = "/TenantBaseExternal/api/v5/Offer/GetByTimeWindow";
|
||||
|
||||
public static String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
public static String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
|
||||
public static String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
|
||||
public static String userInfoUrl = "/UserFrameworkApiV3/api/v1/staffs/Get";
|
||||
|
||||
public static String deppartmentUrl = "/UserFrameworkApiV3/api/v1/departments/Get";
|
||||
|
||||
public static String jobRequirementUrl = "/RecruitV6/api/v1/Requirement/CreateRequirement";
|
||||
|
||||
public static String assessmentFormTable = "uf_jxsjtz";
|
||||
|
||||
public static String assessmentFilterUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByFilters";
|
||||
|
||||
public static String beishenAssessHost = "http://api.beisenapp.com";
|
||||
|
||||
public static String tenantId = "431582";
|
||||
public static String queryAssessUrl = "/Assess/"+Constants.tenantId+"/activity/testee/result/email";
|
||||
|
||||
public static String beisenAccount = "jiekou@test-chabaidao.com";
|
||||
|
||||
public static String consumerKey = "594581d3d5444778a168bb511deb70f7"; // AppKey
|
||||
|
||||
public static String consumerSecret = "6bdef18164794475ac38233c2af4ba01"; // AppSecret
|
||||
|
||||
public static String accessToken = "ae32056b4f6d45199ab036e817dfd98f"; // Token
|
||||
|
||||
public static String tokenSecret = "2e99b9da11cf4ce591a063457a23d5ed"; // Secret
|
||||
|
||||
public static String oauthSignatureMethod = "HMAC-SHA1";
|
||||
|
||||
public static String oauthVersion = "1.0";
|
||||
|
||||
public static String format = "json";
|
||||
|
||||
public static String nyyqzdm = "extnianlingyaoqiu_431582_2032843164";
|
||||
|
||||
//职位(新)
|
||||
public static String zwzd = "extzhiweixin_431582_698711961";
|
||||
public static String unRelateRequirementUrl = "/RecruitV6/api/v1/Requirement/OperateRequirementBeforeCheck";
|
||||
|
||||
public static String positionUrl = "/TenantBaseExternal/api/v5/Position/GetByTimeWindow";
|
||||
|
||||
public static String beisenPostionTable = "uf_bs_gw";
|
||||
|
||||
public static String hrmPostionTable = "eteams.ft_1155455711525494797";
|
||||
|
||||
public static String queryUserIdByEmailUrl = "/TenantBaseExternal/api/v5/Employee/GetUserIDByEmail";
|
||||
|
||||
public static String queryUserIdByCodeUrl = "/TenantBaseExternal/api/v5/Employee/GetUserIDsByJobNumbers";
|
||||
|
||||
public static String queryDeptIdByCodeUrl = "/TenantBaseExternal/api/v5/Organization/GetOrganizationInfoByCodes";
|
||||
|
||||
|
||||
public static String query360AssessmentUrl = "/I360API/api/opencustom/getpersonelscoredataapi";
|
||||
|
||||
public static String assessment360Table = "uf_cpjg";
|
||||
|
||||
public static String zpssyfzd = "extzhaoxushishiyuefen_431582_1686993167";
|
||||
public static String jjcdzdm = "extzhaopinjinjidu_431582_1886847991";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.controller;
|
||||
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 离职年假转换 POC开发的
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbdhr/annual")
|
||||
public class ConversionResignController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ConversionResignController.class);
|
||||
|
||||
@Autowired
|
||||
ConversionResignService conversionResignService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/resignConversion")
|
||||
public WeaResult<Object> resignConversion(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
Map<String,Object> recordMap = conversionResignService.resignConversion(paraMap);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/resignConversion2")
|
||||
public WeaResult<Object> resignConversion2(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
Map<String,Object> recordMap = conversionResignService.resignConversion2(paraMap);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.EmployeePointsDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderUtils;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 积分计算 POC开发的
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbdhr/points")
|
||||
public class EmployeePointsController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(EmployeePointsController.class);
|
||||
|
||||
@Autowired
|
||||
ConversionResignService conversionResignService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@Autowired
|
||||
EmployeePointsDao employeePointsDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderUtils ebuilderUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/getpoints")
|
||||
public WeaResult<Object> resignConversion(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
List<Map<String, Object>> interviewerList = employeePointsDao.queryInterviewerList();
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
log.error("interviewerList:"+interviewerList.size());
|
||||
recordMap.put("interviewerList",interviewerList.size());
|
||||
recordList.add(recordMap);
|
||||
|
||||
for(int i=0;i<interviewerList.size();i++){
|
||||
|
||||
recordMap = new HashMap<String,Object>();
|
||||
|
||||
/**
|
||||
* 招聘阶段
|
||||
*/
|
||||
String stage_id = String.valueOf(interviewerList.get(i).get("stage_id"));
|
||||
/**
|
||||
* 人才ID
|
||||
*/
|
||||
String talent_id = String.valueOf(interviewerList.get(i).get("talent_id"));
|
||||
/***
|
||||
* 推荐人ID
|
||||
*/
|
||||
String referrer_id = String.valueOf(interviewerList.get(i).get("referrer_id"));
|
||||
|
||||
|
||||
log.error("stage_id:"+stage_id);
|
||||
log.error("talent_id:"+talent_id);
|
||||
log.error("referrer_id:"+referrer_id);
|
||||
|
||||
recordMap.put("stage_id",stage_id);
|
||||
recordMap.put("talent_id",talent_id);
|
||||
recordMap.put("referrer_id",referrer_id);
|
||||
|
||||
int points = 0;
|
||||
|
||||
/***
|
||||
* 出试
|
||||
*/
|
||||
if("937153853968544649".equals(stage_id)){
|
||||
points = 100;
|
||||
|
||||
}else if("937153853968544650".equals(stage_id)){
|
||||
/***
|
||||
* 部门筛选
|
||||
*/
|
||||
points = 200;
|
||||
}else if("937153853968544653".equals(stage_id)){
|
||||
/***
|
||||
* 待入职
|
||||
*/
|
||||
points = 500;
|
||||
}
|
||||
log.error("points:{}",points);
|
||||
|
||||
recordMap.put("points",points);
|
||||
|
||||
if(points > 0){
|
||||
Map<String,Object> pointsMap = employeePointsDao.queryPointsByEmployeeId(referrer_id);
|
||||
/***
|
||||
* 积分主表id
|
||||
*/
|
||||
String mainid = String.valueOf(pointsMap.get("id"));
|
||||
if("null".equals(mainid) || mainid == null){
|
||||
mainid = "";
|
||||
}
|
||||
/**
|
||||
* 积分主表form_data_id
|
||||
*/
|
||||
String pointsFormDataId= String.valueOf(pointsMap.get("form_data_id"));
|
||||
if("null".equals(pointsFormDataId) || pointsFormDataId == null){
|
||||
pointsFormDataId = "";
|
||||
}
|
||||
|
||||
log.error("mainid:{}",mainid);
|
||||
log.error("pointsFormDataId:{}",pointsFormDataId);
|
||||
|
||||
recordMap.put("mainid",mainid);
|
||||
recordMap.put("pointsFormDataId",pointsFormDataId);
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = null;
|
||||
if(StringUtils.isNotBlank(mainid)){
|
||||
|
||||
recordMap.put("num","1");
|
||||
String detailId = employeePointsDao.queryPointsDeatilByEmployeeId(talent_id,pointsFormDataId);
|
||||
log.error("detailId:{}",detailId);
|
||||
|
||||
recordMap.put("detailId",detailId);
|
||||
if(StringUtils.isNotBlank(detailId)){
|
||||
recordMap.put("num","2");
|
||||
employeePointsDao.updatePointsDeatilByFormDataId(talent_id,pointsFormDataId,points);
|
||||
employeePointsDao.updatePointsTotalByFormDataId(pointsFormDataId);
|
||||
|
||||
}else{
|
||||
recordMap.put("num","3");
|
||||
ebDataChangeResult = ebuilderUtils.bacthAppendEbDetail(talent_id,points,pointsFormDataId);
|
||||
boolean status = false;
|
||||
String message = "";
|
||||
if(ebDataChangeResult != null){
|
||||
status = ebDataChangeResult.getStatus() ;
|
||||
message = ebDataChangeResult.getMessage();
|
||||
}
|
||||
log.error("message:{}",message);
|
||||
if(status){
|
||||
employeePointsDao.updatePointsTotalByFormDataId(pointsFormDataId);
|
||||
}
|
||||
recordMap.put("status",status);
|
||||
recordMap.put("message",message);
|
||||
}
|
||||
}else{
|
||||
recordMap.put("num","4");
|
||||
ebDataChangeResult = ebuilderUtils.bacthInsertDbForm(referrer_id,points,talent_id);
|
||||
boolean status = false;
|
||||
String message = "";
|
||||
if(ebDataChangeResult != null){
|
||||
status = ebDataChangeResult.getStatus() ;
|
||||
message = ebDataChangeResult.getMessage();
|
||||
}
|
||||
log.error("message:{}",message);
|
||||
log.error("status:{}",status);
|
||||
|
||||
recordMap.put("status",status);
|
||||
recordMap.put("message",message);
|
||||
|
||||
}
|
||||
}else{
|
||||
recordMap.put("message","积分为空");
|
||||
}
|
||||
recordList.add(recordMap);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("message",e.getMessage());
|
||||
recordList.add(recordMap);
|
||||
}
|
||||
return WeaResult.success(recordList);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/***
|
||||
* 离职年假转换 POC开发的
|
||||
*/
|
||||
@Component
|
||||
public class ConversionResignDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConversionResignDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryEmployeeById(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String hiredate = "";
|
||||
try{
|
||||
String dataSql =" select hiredate " +
|
||||
" from eteams.employee " +
|
||||
" where id = '"+employeeId+"' \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = '"+Constants.TENANT_KEY+"' " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
hiredate = String.valueOf(recordMap.get("hiredate"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return hiredate;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param employeeid
|
||||
* @param lznf
|
||||
* @return
|
||||
*/
|
||||
public Double queryEmployeeAnnualLeave(String employeeid,String lznf){
|
||||
String groupId = "weaver-salary-report";
|
||||
String sourceType = "LOGIC";
|
||||
Double annualBase = 0.0;
|
||||
try{
|
||||
String dataSql =" select base " +
|
||||
" from attend_vacation_info_v2 " +
|
||||
" where employee = ? \n" +
|
||||
" and year = ? " +
|
||||
" and tenant_key= ?\n" +
|
||||
" and DELETE_TYPE = 0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
|
||||
paramList.add(employeeid);
|
||||
paramList.add(lznf);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
String base = String.valueOf(recordMap.get("base"));
|
||||
if(StringUtils.isNotBlank(base)){
|
||||
annualBase = Double.valueOf(base);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
annualBase = 0.0 ;
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return annualBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* 积分计算 POC开发的
|
||||
*/
|
||||
@Component
|
||||
public class EmployeePointsDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EmployeePointsDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
public Map<String,Object> queryPointsByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select id,form_data_id " +
|
||||
" from uf_jfgl " +
|
||||
" where ry = ? \n" +
|
||||
" and delete_type=0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> queryInterviewerList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>(100);
|
||||
try{
|
||||
// String dataSql =" select id,referrer_id,recruit_status " +
|
||||
// " from uf_rcrt_talent " +
|
||||
// " where referrer_id is not null \n" +
|
||||
// " and delete_type=0 \n" +
|
||||
// " and tenant_key = ? " ;
|
||||
|
||||
String dataSql =" select t.id,\n" +
|
||||
" t.talent_id,\n" +
|
||||
" t.stage_id,\n" +
|
||||
" t.candidate_id,\n" +
|
||||
" k.referrer_id\n" +
|
||||
" from uf_rcrt_candidate_stage t \n" +
|
||||
" inner join uf_rcrt_candidate_batch p on p.id = t.candidate_id\n" +
|
||||
" left join uf_rcrt_talent k on k.id = t.talent_id\n" +
|
||||
" where t.arrive_status =1\n" +
|
||||
" and p.archive_status = '840811264954613765' " +
|
||||
" and t.delete_type=0 \n" +
|
||||
" and t.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" and k.delete_type=0 \n" +
|
||||
" and k.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" and p.delete_type=0 \n" +
|
||||
" and p.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<String>(100);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}" ,recordList.size());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
public String queryPointsDeatilByEmployeeId(String rcid,String form_data_id){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String detailId = "";
|
||||
try{
|
||||
String dataSql =" select id,form_data_id " +
|
||||
" from uf_jfgl_mxb1 " +
|
||||
" where rcxx = ? " +
|
||||
" and form_data_id = ? \n" +
|
||||
" and delete_type=0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(rcid);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
detailId = String.valueOf(recordMap.get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return detailId;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> updatePointsDeatilByFormDataId(String rcid,String form_data_id,int jf){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" update uf_jfgl_mxb1 set hqjf = " + jf +
|
||||
" where rcxx = ? and form_data_id = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(rcid);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> updatePointsTotalByFormDataId(String form_data_id){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" update uf_jfgl set jf = (select ifnull(sum(hqjf),0) as hqjf from uf_jfgl_mxb1 where form_data_id= ? and delete_type = 0 and tenant_key = ? ) " +
|
||||
" where form_data_id = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param employeeid
|
||||
* @param lznf
|
||||
* @return
|
||||
*/
|
||||
public Double queryEmployeeAnnualLeave(String employeeid,String lznf){
|
||||
String groupId = "weaver-salary-report";
|
||||
String sourceType = "LOGIC";
|
||||
Double annualBase = 0.0;
|
||||
try{
|
||||
String dataSql =" select base " +
|
||||
" from attend_vacation_info_v2 " +
|
||||
" where employee = ? \n" +
|
||||
" and year = ? " +
|
||||
" and tenant_key= ?\n" +
|
||||
" and DELETE_TYPE = 0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
|
||||
paramList.add(employeeid);
|
||||
paramList.add(lznf);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
String base = String.valueOf(recordMap.get("base"));
|
||||
if(StringUtils.isNotBlank(base)){
|
||||
annualBase = Double.valueOf(base);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
annualBase = 0.0 ;
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return annualBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/***
|
||||
* 360测评
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class HrmAssessment360Dao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmAssessment360Dao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
* 判断360测评数据在Eb表是否存在
|
||||
* @return
|
||||
*/
|
||||
public String getAssessment360Data(String gh,String hdid,String wjid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String id = "";
|
||||
try{
|
||||
String dataSql =" select id from " +Constants.assessment360Table +
|
||||
" where gh = ? " +
|
||||
" and hdid = ? " +
|
||||
" and wjid = ? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(gh);
|
||||
paramList.add(hdid);
|
||||
paramList.add(wjid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
id = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据工号获取人员ID
|
||||
* @param jobNum
|
||||
* @return
|
||||
*/
|
||||
public String queryEmployeeJobNumData(String jobNum){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String employeeId = "";
|
||||
try{
|
||||
String dataSql =" select id from eteams.employee where job_num = ? and tenant_key=? and delete_type = 0" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(jobNum);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
employeeId = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> queryEmployeeEmail(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
|
||||
String dataSql =" select id,email from eteams.employee \n" +
|
||||
" where tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" ,e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,260 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class HrmAssessmentNewDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmAssessmentNewDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAssessmentData(String khnf,String khzq,String jxhdid,String bkhr){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String id = "";
|
||||
try{
|
||||
String dataSql =" select id from uf_jxsjtz " +
|
||||
" where khnf = ? " +
|
||||
" and khzq = ? " +
|
||||
" and jxhdid = ? " +
|
||||
" and bkhr = ? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(khnf);
|
||||
paramList.add(khzq);
|
||||
paramList.add(jxhdid);
|
||||
paramList.add(bkhr);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
id = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String form_id = "";
|
||||
try{
|
||||
String dataSql =" select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
form_id = String.valueOf(recordMap.get("form_id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return form_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from eteams.form_field " +
|
||||
" where form_id in( select form_id from eteams.form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String queryEmailByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String gryx = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select k.gryx from eteams.employee t\n" +
|
||||
" inner join eteams.ft_1152026012537184302 k on k.id = t.formdata\n" +
|
||||
" where t.id=? " +
|
||||
" and t.tenant_key=? \n" +
|
||||
" and t.delete_type=0" +
|
||||
" and k.tenant_key=? \n" +
|
||||
" and k.delete_type=0";
|
||||
|
||||
log.error("queryEmailByEmployeeId--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryEmailByEmployeeId:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
gryx = String.valueOf(recordList.get(0).get("gryx"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryEmailByEmployeeId:e:" + e);
|
||||
}
|
||||
return gryx;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryDepartmentData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select code,id from eteams.department where status = 1 " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Map<String, Object> queryEmployeeAssessmentOtherInfo(String employeeid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> employeeMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select hiredate as rzrq,zhgzr as lzrq,zzrq,personnel_status as ryzt,subcompany as gs,yjbm as bm1,ejbm as bm2,sanjbm as bm3,sijbm as bm4,rylb,location as gzdd" +
|
||||
" from uf_jcl_employee_information \n" +
|
||||
" where id = ? " +
|
||||
" and tenant_key = ? \n" +
|
||||
" and delete_type = 0 " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
employeeMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}", e);
|
||||
}
|
||||
return employeeMap;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> queryEmployeeEmail(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
|
||||
String dataSql =" select id,email from eteams.employee \n" +
|
||||
" where tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" ,e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 北森岗位数据同步
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class HrmBeisenPositionDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmBeisenPositionDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
* 根据北森岗位id获取ebid
|
||||
* @return
|
||||
*/
|
||||
public String getPositionIdByGwId(String gwid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String id = "";
|
||||
try{
|
||||
String dataSql =" select id from " +Constants.beisenPostionTable +
|
||||
" where bs_gwid = ? " +
|
||||
" and tenant_key = ? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(gwid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
id = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新岗位信息
|
||||
* @param code
|
||||
* @param objectId
|
||||
* @param oIdOrganization
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> updateHrmPositionByBensen(String code,String objectId,String oIdOrganization){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" update " +Constants.hrmPostionTable + " set oid=?,odeptid=? "+
|
||||
" where code = ? " +
|
||||
" and tenant_key = ? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(objectId);
|
||||
paramList.add(oIdOrganization);
|
||||
paramList.add(code);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
result = databaseUtils.executeForUpdate(sourceType, groupId, dataSql, sqlParamList);
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class HrmDepartmentDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmDepartmentDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public String getDepartmentCodeById(String deptId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String code = "";
|
||||
try{
|
||||
String dataSql =" select code from eteams.department where id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(deptId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("getDepartmentCodeById:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
code = String.valueOf(recordList.get(0).get("code"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// public String queryEmailByEmployeeId(String employeeId){
|
||||
// String groupId = "weaver-ebuilder-form-service";
|
||||
// String sourceType = "LOGIC";
|
||||
// String gryx = "";
|
||||
// try{
|
||||
//
|
||||
// String dataSql =" select k.gryx from eteams.employee t\n" +
|
||||
// " inner join eteams.ft_1152026012537184302 k on k.id = t.formdata\n" +
|
||||
// " where t.id=? " +
|
||||
// " and t.tenant_key=? \n" +
|
||||
// " and t.delete_type=0" +
|
||||
// " and k.tenant_key=? \n" +
|
||||
// " and k.delete_type=0";
|
||||
//
|
||||
// log.error("queryEmailByEmployeeId--dataSql:" + dataSql);
|
||||
// List<String> paramList = new ArrayList<>(100);
|
||||
// paramList.add(employeeId);
|
||||
// paramList.add(Constants.TENANT_KEY);
|
||||
// paramList.add(Constants.TENANT_KEY);
|
||||
//
|
||||
// List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
// Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
// List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
// log.error("queryEmailByEmployeeId:"+recordList.size());
|
||||
// if(recordList.size() > 0){
|
||||
// gryx = String.valueOf(recordList.get(0).get("gryx"));
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// log.error("queryEmailByEmployeeId:e:" + e);
|
||||
// }
|
||||
// return gryx;
|
||||
// }
|
||||
|
||||
|
||||
public Map<String,Object> queryDepartmentData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select code,id from eteams.department where status = 1 " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryEmployeeData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select job_num,id from eteams.employee where tenant_key=? and delete_type = 0" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String job_num = String.valueOf(recordMap.get("job_num"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(job_num,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class HrmEmployeeDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmEmployeeDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
public String queryPersonalEmailByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String gryx = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select k.gryx from eteams.employee t\n" +
|
||||
" inner join eteams.ft_1152026012537184302 k on k.id = t.formdata\n" +
|
||||
" where t.id=? " +
|
||||
" and t.tenant_key=? \n" +
|
||||
" and t.delete_type=0" +
|
||||
" and k.tenant_key=? \n" +
|
||||
" and k.delete_type=0";
|
||||
|
||||
log.error("queryEmailByEmployeeId--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryEmailByEmployeeId:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
gryx = String.valueOf(recordList.get(0).get("gryx"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryEmailByEmployeeId:e:" + e);
|
||||
}
|
||||
return gryx;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryEmployeeData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select job_num,id from eteams.employee where tenant_key=? and delete_type = 0" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String job_num = String.valueOf(recordMap.get("job_num"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(job_num,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class HrmFormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmFormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
|
||||
/***
|
||||
* 获取eb表的appid和formid
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Eb表的字段信息
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取下拉框的名称
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String queryTableFormIdByTableName(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String form_id = "";
|
||||
try{
|
||||
String dataSql =" select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(com.weaver.seconddev.chapanda.beisen.constant.Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
form_id = String.valueOf(recordMap.get("form_id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return form_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class HrmPerformanceDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmPerformanceDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAssessmentData(String khnf,String khzq,String jxhdid,String bkhr){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String id = "";
|
||||
try{
|
||||
String dataSql =" select id from uf_jxsjtz " +
|
||||
" where khnf = ? " +
|
||||
" and khzq = ? " +
|
||||
" and jxhdid = ? " +
|
||||
" and bkhr = ? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(khnf);
|
||||
paramList.add(khzq);
|
||||
paramList.add(jxhdid);
|
||||
paramList.add(bkhr);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
id = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Map<String, Object> queryEmployeeAssessmentOtherInfo(String employeeid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> employeeMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select hiredate as rzrq,zhgzr as lzrq,zzrq,personnel_status as ryzt,subcompany as gs,yjbm as bm1,ejbm as bm2,sanjbm as bm3,sijbm as bm4,rylb,location as gzdd" +
|
||||
" from uf_jcl_employee_information \n" +
|
||||
" where glzzyg = ? " +
|
||||
" and tenant_key = ? \n" +
|
||||
" and delete_type = 0 " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
employeeMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}", e);
|
||||
}
|
||||
return employeeMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenDepartmentDto {
|
||||
int orgId;
|
||||
String name;
|
||||
String code;
|
||||
String abbreviation;
|
||||
String parentOriginalId;
|
||||
String originalId;
|
||||
String status;
|
||||
String isDelete;
|
||||
String orderId;
|
||||
|
||||
public int getOrgId() {
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public void setOrgId(int orgId) {
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getParentOriginalId() {
|
||||
return parentOriginalId;
|
||||
}
|
||||
|
||||
public void setParentOriginalId(String parentOriginalId) {
|
||||
this.parentOriginalId = parentOriginalId;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenHireRequestDto {
|
||||
int requirementStatus;
|
||||
int requirementType;
|
||||
String name;
|
||||
int createBy;
|
||||
String createDate;
|
||||
String arivalTime;
|
||||
String dutyUserEmail;
|
||||
String createByEmail;
|
||||
int departmentId;
|
||||
int requirementCount;
|
||||
int salaryType;
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffDepartmentDto {
|
||||
String id;
|
||||
String name;
|
||||
String code;
|
||||
String abbreviation;
|
||||
String parentId;
|
||||
String level;
|
||||
String status;
|
||||
String originalId;
|
||||
String isDelete;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,286 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffDto {
|
||||
String departmentId;
|
||||
String departmentName;
|
||||
String employedDate;
|
||||
String jobCode;
|
||||
String positionName;
|
||||
String lineManagerId;
|
||||
String staffCode;
|
||||
String staffStatus;
|
||||
String isDelete;
|
||||
int userId;
|
||||
String tenantId;
|
||||
String email;
|
||||
String userType;
|
||||
String userStatus;
|
||||
String origin;
|
||||
String originalId;
|
||||
String name;
|
||||
String englishName;
|
||||
String sex;
|
||||
|
||||
String birthday;
|
||||
String mobile;
|
||||
String idCardType;
|
||||
String idCardNumber;
|
||||
String graduateDate;
|
||||
String nativePlace;
|
||||
String beganWorkDate;
|
||||
String graduateFrom;
|
||||
String major;
|
||||
String positionCategory;
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto;
|
||||
BeisenStaffPositionDto beisenStaffPositionDto;
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getEmployedDate() {
|
||||
return employedDate;
|
||||
}
|
||||
|
||||
public void setEmployedDate(String employedDate) {
|
||||
this.employedDate = employedDate;
|
||||
}
|
||||
|
||||
public String getJobCode() {
|
||||
return jobCode;
|
||||
}
|
||||
|
||||
public void setJobCode(String jobCode) {
|
||||
this.jobCode = jobCode;
|
||||
}
|
||||
|
||||
public String getPositionName() {
|
||||
return positionName;
|
||||
}
|
||||
|
||||
public void setPositionName(String positionName) {
|
||||
this.positionName = positionName;
|
||||
}
|
||||
|
||||
public String getLineManagerId() {
|
||||
return lineManagerId;
|
||||
}
|
||||
|
||||
public void setLineManagerId(String lineManagerId) {
|
||||
this.lineManagerId = lineManagerId;
|
||||
}
|
||||
|
||||
public String getStaffCode() {
|
||||
return staffCode;
|
||||
}
|
||||
|
||||
public void setStaffCode(String staffCode) {
|
||||
this.staffCode = staffCode;
|
||||
}
|
||||
|
||||
public String getStaffStatus() {
|
||||
return staffStatus;
|
||||
}
|
||||
|
||||
public void setStaffStatus(String staffStatus) {
|
||||
this.staffStatus = staffStatus;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(String userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
public String getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(String origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getIdCardType() {
|
||||
return idCardType;
|
||||
}
|
||||
|
||||
public void setIdCardType(String idCardType) {
|
||||
this.idCardType = idCardType;
|
||||
}
|
||||
|
||||
public String getIdCardNumber() {
|
||||
return idCardNumber;
|
||||
}
|
||||
|
||||
public void setIdCardNumber(String idCardNumber) {
|
||||
this.idCardNumber = idCardNumber;
|
||||
}
|
||||
|
||||
public String getGraduateDate() {
|
||||
return graduateDate;
|
||||
}
|
||||
|
||||
public void setGraduateDate(String graduateDate) {
|
||||
this.graduateDate = graduateDate;
|
||||
}
|
||||
|
||||
public String getNativePlace() {
|
||||
return nativePlace;
|
||||
}
|
||||
|
||||
public void setNativePlace(String nativePlace) {
|
||||
this.nativePlace = nativePlace;
|
||||
}
|
||||
|
||||
public String getBeganWorkDate() {
|
||||
return beganWorkDate;
|
||||
}
|
||||
|
||||
public void setBeganWorkDate(String beganWorkDate) {
|
||||
this.beganWorkDate = beganWorkDate;
|
||||
}
|
||||
|
||||
public String getGraduateFrom() {
|
||||
return graduateFrom;
|
||||
}
|
||||
|
||||
public void setGraduateFrom(String graduateFrom) {
|
||||
this.graduateFrom = graduateFrom;
|
||||
}
|
||||
|
||||
public String getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public void setMajor(String major) {
|
||||
this.major = major;
|
||||
}
|
||||
|
||||
public String getPositionCategory() {
|
||||
return positionCategory;
|
||||
}
|
||||
|
||||
public void setPositionCategory(String positionCategory) {
|
||||
this.positionCategory = positionCategory;
|
||||
}
|
||||
|
||||
public BeisenStaffDepartmentDto getBeisenStaffDepartmentDto() {
|
||||
return beisenStaffDepartmentDto;
|
||||
}
|
||||
|
||||
public void setBeisenStaffDepartmentDto(BeisenStaffDepartmentDto beisenStaffDepartmentDto) {
|
||||
this.beisenStaffDepartmentDto = beisenStaffDepartmentDto;
|
||||
}
|
||||
|
||||
public BeisenStaffPositionDto getBeisenStaffPositionDto() {
|
||||
return beisenStaffPositionDto;
|
||||
}
|
||||
|
||||
public void setBeisenStaffPositionDto(BeisenStaffPositionDto beisenStaffPositionDto) {
|
||||
this.beisenStaffPositionDto = beisenStaffPositionDto;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffPositionDto {
|
||||
String id;
|
||||
String name;
|
||||
String code;
|
||||
String status;
|
||||
String isDelete;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeisenAssessUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenAssessCronJob")
|
||||
public class Esb2BeisenAssessCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenAssessCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Esb2BeisenAssessUtil esb2BeisenAssessUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String emails = String.valueOf(params.get("emails"));
|
||||
log.error("emails:{}",emails);
|
||||
esb2BeisenAssessUtil.queryAssessData(emails);
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmAssessment360Dao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenAssessment360Util;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenAssessment360Action")
|
||||
public class Esb2BeisenAssessment360Action implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenAssessment360Action.class);
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenAssessment360Util esb2BeiSenAssessment360Util;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
HrmAssessment360Dao hrmAssessment360Dao;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("ryid");
|
||||
fieldList.add("gsyx");
|
||||
fieldList.add("gh");
|
||||
fieldList.add("hdid");
|
||||
fieldList.add("hdmc");
|
||||
fieldList.add("wjid");
|
||||
fieldList.add("wjmc");
|
||||
fieldList.add("zzjg");
|
||||
fieldList.add("cjsj");
|
||||
fieldList.add("wcsj");
|
||||
|
||||
log.error("Esb2BeisenAssessment360Action");
|
||||
|
||||
String employeeid = String.valueOf(params.get("employeeid"));
|
||||
log.error("employeeid:{}",employeeid);
|
||||
if(StringUtils.isNotBlank(employeeid)){
|
||||
Long employeeId = Long.valueOf(employeeid);
|
||||
log.error("employeeId:{}",employeeId);
|
||||
SimpleEmployee createByEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
String email = createByEmployee.getEmail();
|
||||
log.error("email:{}",email);
|
||||
JSONArray assessmentArray = esb2BeiSenAssessment360Util.convertAssessmentData(email);
|
||||
log.error("assessmentArray:{}",assessmentArray.size());
|
||||
|
||||
Map<String, Object> fieldMap = hrmFormFieldDao.queryFromTableField(Constants.assessment360Table,fieldList);
|
||||
log.error("fieldMap:{}",fieldMap.size());
|
||||
|
||||
List<EBDataReqDto> addDatas = new ArrayList<EBDataReqDto>();
|
||||
for(int i=0;i<assessmentArray.size();i++){
|
||||
JSONObject dataJson = assessmentArray.getJSONObject(i);
|
||||
log.error("dataJson:{}",dataJson.toJSONString());
|
||||
|
||||
if(dataJson.containsKey("gh") && dataJson.containsKey("hdid") && dataJson.containsKey("wjid")){
|
||||
String gh = dataJson.getString("gh");
|
||||
String hdid = dataJson.getString("hdid");
|
||||
String wjid = dataJson.getString("wjid");
|
||||
|
||||
log.error("gh:{}",gh);
|
||||
log.error("hdid:{}",hdid);
|
||||
log.error("wjid:{}",wjid);
|
||||
|
||||
String ryid = "";
|
||||
if(StringUtils.isNotBlank(gh)){
|
||||
ryid = hrmAssessment360Dao.queryEmployeeJobNumData(gh);
|
||||
}
|
||||
log.error("ryid:{}",ryid);
|
||||
|
||||
dataJson.put("ryid",ryid);
|
||||
|
||||
String ufId = hrmAssessment360Dao.getAssessment360Data(gh,hdid,wjid);
|
||||
log.error("ufId:{}",ufId);
|
||||
|
||||
if(StringUtils.isBlank(ufId)){
|
||||
log.error("新增");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
log.error("fieldid:{}",fieldList.get(n));
|
||||
log.error("fieldid2:{}",dataJson.containsKey(fieldList.get(n)));
|
||||
log.error("fieldid3:{}",fieldMap.containsKey(fieldList.get(n)));
|
||||
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
addDatas.add(ebDataReqDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("addDatas:{}",addDatas.size());
|
||||
|
||||
Map<String,Object> recordMap = hrmFormFieldDao.queryTableFormId(Constants.assessment360Table);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
if(addDatas.size() > 0){
|
||||
EBDataChangeResult addEbDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(addDatas,formId,appId);
|
||||
boolean isTrue = addEbDataChangeResult.getStatus();
|
||||
log.error("message:{}",addEbDataChangeResult.getMessage());
|
||||
log.error("isTrue1:{}",isTrue);
|
||||
if(isTrue){
|
||||
ebList.addAll(addEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
actionMap.put("ebList",ebList.size());
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmBeisenPositionDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenAssessment360Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenAssessment360FullCronJob")
|
||||
public class Esb2BeisenAssessment360FullCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenAssessment360FullCronJob.class);
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
|
||||
@Autowired
|
||||
HrmBeisenPositionDao hrmBeisenPositionDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenAssessment360Util esb2BeiSenAssessment360Util;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
|
||||
esb2BeiSenAssessment360Util.queryAssessment360Data();
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,103 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.*;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenCreateBlackListAction")
|
||||
public class Esb2BeisenCreateBlackListAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenCreateBlackListAction.class);
|
||||
|
||||
@Autowired
|
||||
BlackList2BeiSenUtil blackList2BeiSenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
// @Autowired
|
||||
// BeisenStaffInfoByStaffCodeUtil beisenStaffInfoByStaffCodeUtil;
|
||||
|
||||
|
||||
@Autowired
|
||||
BeisenQueryUseridUtil beisenQueryUseridUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("EsbRequestSubmitAction start");
|
||||
// String beisenUserId = (String) params.get("beisenuserid");
|
||||
Long userId = 0L;
|
||||
if(params.containsKey("userid")){
|
||||
String userIdStr = String.valueOf(params.get("userid"));
|
||||
log.error("userIdStr:{}",userIdStr);
|
||||
if(StringUtils.isNotBlank(userIdStr)){
|
||||
userId = Long.valueOf(userIdStr);
|
||||
}
|
||||
}
|
||||
|
||||
String lastWorkDate = (String) params.get("lastworkdate");
|
||||
String blackAddReason = (String) params.get("blackaddreason");
|
||||
String blackStaffDesc = (String) params.get("blackstaffdesc");
|
||||
String name = (String) params.get("name");
|
||||
String staffemail = (String) params.get("staffemail");
|
||||
|
||||
log.error("userId:{}",userId);
|
||||
log.error("lastWorkDate:{}",lastWorkDate);
|
||||
log.error("blackAddReason:{}",blackAddReason);
|
||||
log.error("blackStaffDesc:{}",blackStaffDesc);
|
||||
log.error("name:{}",name);
|
||||
log.error("staffemail:{}",staffemail);
|
||||
int beisenUserId = -1;
|
||||
String jobNum = "";
|
||||
if(userId.longValue() >0){
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(userId);
|
||||
jobNum = simpleEmployee.getJobNum();
|
||||
}
|
||||
|
||||
log.error("jobNum:{}",jobNum);
|
||||
if(StringUtils.isNotBlank(jobNum)){
|
||||
|
||||
String beisenUser = beisenQueryUseridUtil.queryBeisenUserIdByJobNum(jobNum);
|
||||
if(StringUtils.isNotBlank(beisenUser)){
|
||||
beisenUserId = Integer.valueOf(beisenUser);
|
||||
}
|
||||
// BeisenStaffDto beisenStaffDto = beisenStaffInfoByStaffCodeUtil.getBeisenStaffInfoByStaffCode(jobNum);
|
||||
}
|
||||
log.error("beisenUserId:{}",beisenUserId);
|
||||
|
||||
// String tokenUrl = "https://openapi.italent.cn/token";
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
// String createBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/Create";
|
||||
// String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
// String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
String objectId = "";
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
if(beisenUserId > 0){
|
||||
objectId = blackList2BeiSenUtil.createBlackList4ResignUser(token,String.valueOf(beisenUserId),lastWorkDate,blackAddReason,blackStaffDesc);
|
||||
}else{
|
||||
objectId = blackList2BeiSenUtil.createBlackList4NonSystem(token,name,staffemail,blackAddReason,blackStaffDesc);
|
||||
}
|
||||
}
|
||||
|
||||
log.error("objectId:{}",objectId);
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenCreateBlackListAction");
|
||||
actionMap.put("objectId",objectId);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.BlackList2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenDeleteBlackListAction")
|
||||
public class Esb2BeisenDeleteBlackListAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenDeleteBlackListAction.class);
|
||||
|
||||
@Autowired
|
||||
BlackList2BeiSenUtil blackList2BeiSenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenDeleteBlackListAction start");
|
||||
String objectIds = (String) params.get("objectIds");
|
||||
log.error("objectIds:{}",objectIds);
|
||||
|
||||
String msg = "";
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
List<String> userIds = Arrays.asList(objectIds.split(","));
|
||||
msg = blackList2BeiSenUtil.batchDeleteBlackList(token,userIds);
|
||||
}
|
||||
|
||||
String failDatas = "";
|
||||
int failCount = -1 ;
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("failCount")){
|
||||
failCount = dataObject.getInteger("failCount");
|
||||
failDatas = dataObject.getString("failDatas");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenDeleteBlackListAction");
|
||||
actionMap.put("failCount",failCount);
|
||||
actionMap.put("failDatas",failDatas);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.cache.HrmDepartmentComInfo;
|
||||
import com.weaver.common.hrm.manage.HrmComInfoCacheHandler;
|
||||
import com.weaver.common.hrm.remote.department.HrmRemoteDepartmentService;
|
||||
import com.weaver.common.hrm.service.HrmCommonDepartmentService;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmDepartmentDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.*;
|
||||
import com.weaver.teams.domain.department.SimpleDepartment;
|
||||
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenJobRequirementAction")
|
||||
public class Esb2BeisenJobRequirementAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenJobRequirementAction.class);
|
||||
|
||||
@Autowired
|
||||
JobRequirement2BeisenUtil jobRequirement2BeisenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
DatabaseUtils databaseUtils;
|
||||
|
||||
@Autowired
|
||||
BeisenStaffInfoByStaffCodeUtil beisenStaffInfoByStaffCodeUtil ;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmDepartmentDao hrmDepartmentDao;
|
||||
|
||||
@Autowired
|
||||
BeisenQueryUseridUtil beisenQueryUseridUtil;
|
||||
|
||||
@Autowired
|
||||
BeisenQueryDeptIdUtil beisenQueryDeptIdUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenJobRequirementAction start");
|
||||
|
||||
int requirementStatus = converInteger(params,"requirementStatus");
|
||||
String form_data_id = (String) params.get("form_data_id");
|
||||
int requirementType = converInteger(params,"requirementType");
|
||||
|
||||
String requestname = (String) params.get("requestname");
|
||||
String createDate = (String) params.get("createDate");
|
||||
|
||||
int requirementCount = converInteger(params,"requirementCount") ;
|
||||
String arivalTime = (String) params.get("arivalTime");
|
||||
|
||||
int salaryType = converInteger(params,"salaryType");
|
||||
int category = converInteger(params,"category");
|
||||
String educationInfo = (String) params.get("educationInfo");
|
||||
String workExperience = (String) params.get("workExperience");
|
||||
int kind = converInteger(params,"kind");
|
||||
boolean isSecrecy = false;
|
||||
String isSecrecyStr = (String) params.get("isSecrecy");
|
||||
if("1".equals(isSecrecyStr)){
|
||||
isSecrecy = true;
|
||||
}
|
||||
|
||||
String originalId = String.valueOf(params.get("originalId"));
|
||||
|
||||
String nlyq = String.valueOf(params.get("nlyq"));
|
||||
|
||||
log.error("requirementStatus:" + requirementStatus);
|
||||
log.error("originalId:" + originalId);
|
||||
log.error("requirementType:" + requirementType);
|
||||
log.error("requestname:" + requestname);
|
||||
log.error("createDate:" + createDate);
|
||||
log.error("requirementCount:" + requirementCount);
|
||||
log.error("arivalTime:" + arivalTime);
|
||||
log.error("salaryType:" + salaryType);
|
||||
log.error("category:" + category);
|
||||
log.error("educationInfo:" + educationInfo);
|
||||
log.error("workExperience:" + workExperience);
|
||||
log.error("kind:" + kind);
|
||||
log.error("isSecrecy:" + isSecrecy);
|
||||
log.error("form_data_id:" + form_data_id);
|
||||
log.error("nlyq:" + nlyq);
|
||||
|
||||
String createBy = String.valueOf(params.get("createBy"));
|
||||
String dutyUserId = String.valueOf(params.get("dutyUserId"));
|
||||
log.error("createBy:" + createBy);
|
||||
log.error("dutyUserId:" + dutyUserId);
|
||||
|
||||
|
||||
|
||||
String zpgw = String.valueOf(params.get("zpgw"));
|
||||
String zwmc = String.valueOf(params.get("zwmc"));
|
||||
// String createByEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
// log.error("createByEmail:" + createByEmail);
|
||||
// String dutyUserEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
// log.error("dutyUserEmail:" + dutyUserEmail);
|
||||
|
||||
String originalCode = "";
|
||||
if(StringUtils.isNotBlank(originalId)){
|
||||
originalCode = hrmDepartmentDao.getDepartmentCodeById(originalId);
|
||||
}
|
||||
log.error("originalCode:" + originalCode);
|
||||
|
||||
String createByEmail = "";
|
||||
int beisenCreateUserId = -1;
|
||||
if(StringUtils.isNotBlank(createBy)){
|
||||
String jobnum = "";
|
||||
SimpleEmployee createByEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(createBy));
|
||||
if(createByEmployee !=null && createByEmployee.getId() > 0){
|
||||
jobnum = createByEmployee.getJobNum();
|
||||
createByEmail = createByEmployee.getEmail();
|
||||
}
|
||||
log.error("jobnum:" + jobnum);
|
||||
if(StringUtils.isNotBlank(jobnum)){
|
||||
String userid = beisenQueryUseridUtil.queryBeisenUserIdByJobNum(jobnum);
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
beisenCreateUserId = Integer.valueOf(userid);
|
||||
}
|
||||
log.error("beisenCreateUserId:" + beisenCreateUserId);
|
||||
}
|
||||
}
|
||||
log.error("createByEmail:" + createByEmail);
|
||||
|
||||
|
||||
String dutyUserEmail = "";
|
||||
int beisenDutyUserId = -1;
|
||||
if(StringUtils.isNotBlank(dutyUserId)){
|
||||
String jobnum = "";
|
||||
SimpleEmployee dutyEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(dutyUserId));
|
||||
if(dutyEmployee !=null && dutyEmployee.getId() > 0){
|
||||
jobnum = dutyEmployee.getJobNum();
|
||||
dutyUserEmail = dutyEmployee.getEmail();
|
||||
}
|
||||
log.error("jobnum:" + jobnum);
|
||||
if(StringUtils.isNotBlank(jobnum)){
|
||||
String userid = beisenQueryUseridUtil.queryBeisenUserIdByJobNum(jobnum);
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
beisenDutyUserId = Integer.valueOf(userid);
|
||||
}
|
||||
log.error("beisenDutyUserId:" + beisenDutyUserId);
|
||||
}
|
||||
}
|
||||
log.error("dutyUserEmail:" + dutyUserEmail);
|
||||
|
||||
int orgId = -1;
|
||||
if(StringUtils.isNotBlank(originalCode)){
|
||||
// BeisenDepartmentDto beisenDepartmentDto = beisenDeptInfoByOriginalIdUtil.getBeisenDeptDataByOriginalId(originalId);
|
||||
// log.error("beisenDepartmentDto:{}",beisenDepartmentDto.toString());
|
||||
String deptid = beisenQueryDeptIdUtil.queryBeisenDeptIdByCode(originalCode);
|
||||
if(StringUtils.isNotBlank(deptid)){
|
||||
orgId = Integer.valueOf(deptid);
|
||||
}
|
||||
// orgId = beisenDepartmentDto.getOrgId();
|
||||
}
|
||||
|
||||
String xqmc = (String) params.get("xqmc");
|
||||
String gzzz = String.valueOf(params.get("gzzz"));
|
||||
String rzzg = String.valueOf(params.get("rzzg "));
|
||||
String zxssyf = String.valueOf(params.get("zxssyf"));
|
||||
String jjcd = String.valueOf(params.get("jjcd"));
|
||||
|
||||
log.error("orgId:" + orgId);
|
||||
String dataId = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
|
||||
requestname,beisenCreateUserId,
|
||||
createDate,requirementCount,
|
||||
arivalTime,
|
||||
createByEmail,
|
||||
dutyUserEmail,
|
||||
orgId,
|
||||
salaryType,
|
||||
category,
|
||||
educationInfo,
|
||||
workExperience,
|
||||
kind,
|
||||
isSecrecy,
|
||||
originalCode,nlyq,zpgw,zwmc,beisenDutyUserId,xqmc,gzzz,rzzg,zxssyf,jjcd);
|
||||
|
||||
log.error("dataId:" + dataId);
|
||||
// if(StringUtils.isNotBlank(dataId)){
|
||||
// String sourceType = "";
|
||||
// String groupId = "";
|
||||
//
|
||||
// String dataSql =" update uf_zpxqgl set bszxid = ? " +
|
||||
// " where form_data_id = ?\n" +
|
||||
// " and tenant_key=? \n" +
|
||||
// " and delete_type=0 \n" ;
|
||||
//
|
||||
// log.error("dataSql:" + dataSql);
|
||||
// List<String> paramList = new ArrayList<>(100);
|
||||
//
|
||||
// paramList.add(form_data_id);
|
||||
// paramList.add(Constants.TENANT_KEY);
|
||||
// List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
// result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
// }
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenJobRequirementAction");
|
||||
actionMap.put("dataId",dataId);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public int converInteger(Map<String,Object> params,String key){
|
||||
int value = -1;
|
||||
try{
|
||||
String requirementStatusStr = (String) params.get(key);
|
||||
value = Integer.valueOf(requirementStatusStr);
|
||||
}catch (Exception e){
|
||||
log.error("key:{},e:{}",key,e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmDepartmentDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.*;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* @author: shil
|
||||
* @date: 2025/8/7
|
||||
* @description: 招聘需求创建
|
||||
*/
|
||||
@Service("Esb2BeisenJobRequirementCreateAction")
|
||||
public class Esb2BeisenJobRequirementCreateAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenJobRequirementCreateAction.class);
|
||||
|
||||
@Autowired
|
||||
JobRequirement2BeisenUtil jobRequirement2BeisenUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmDepartmentDao hrmDepartmentDao;
|
||||
|
||||
@Autowired
|
||||
BeisenQueryUseridUtil beisenQueryUseridUtil;
|
||||
|
||||
@Autowired
|
||||
BeisenQueryDeptIdUtil beisenQueryDeptIdUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenJobRequirementAction start");
|
||||
|
||||
int requirementStatus = converInteger(params,"requirementStatus");
|
||||
String form_data_id = (String) params.get("form_data_id");
|
||||
int requirementType = converInteger(params,"requirementType");
|
||||
|
||||
String requestname = (String) params.get("requestname");
|
||||
String createDate = (String) params.get("createDate");
|
||||
String xqmc = (String) params.get("xqmc");
|
||||
|
||||
int requirementCount = converInteger(params,"requirementCount") ;
|
||||
String arivalTime = (String) params.get("arivalTime");
|
||||
|
||||
int salaryType = converInteger(params,"salaryType");
|
||||
int category = converInteger(params,"category");
|
||||
String educationInfo = (String) params.get("educationInfo");
|
||||
String workExperience = (String) params.get("workExperience");
|
||||
int kind = converInteger(params,"kind");
|
||||
boolean isSecrecy = false;
|
||||
String isSecrecyStr = (String) params.get("isSecrecy");
|
||||
if("1".equals(isSecrecyStr)){
|
||||
isSecrecy = true;
|
||||
}
|
||||
|
||||
String originalId = String.valueOf(params.get("originalId"));
|
||||
|
||||
String nlyq = String.valueOf(params.get("nlyq"));
|
||||
|
||||
|
||||
String zpgw = String.valueOf(params.get("zpgw"));
|
||||
String zwmc = String.valueOf(params.get("zwmc"));
|
||||
String zxssyf = String.valueOf(params.get("zxssyf"));
|
||||
String jjcd = String.valueOf(params.get("jjcd"));
|
||||
|
||||
log.error("requirementStatus:" + requirementStatus);
|
||||
log.error("originalId:" + originalId);
|
||||
log.error("requirementType:" + requirementType);
|
||||
log.error("requestname:" + requestname);
|
||||
log.error("createDate:" + createDate);
|
||||
log.error("requirementCount:" + requirementCount);
|
||||
log.error("arivalTime:" + arivalTime);
|
||||
log.error("salaryType:" + salaryType);
|
||||
log.error("category:" + category);
|
||||
log.error("educationInfo:" + educationInfo);
|
||||
log.error("workExperience:" + workExperience);
|
||||
log.error("kind:" + kind);
|
||||
log.error("isSecrecy:" + isSecrecy);
|
||||
log.error("form_data_id:{}" , form_data_id);
|
||||
log.error("nlyq:{}" , nlyq);
|
||||
log.error("zpgw:{}" , zpgw);
|
||||
|
||||
String createBy = String.valueOf(params.get("createBy"));
|
||||
String dutyUserId = String.valueOf(params.get("dutyUserId"));
|
||||
log.error("createBy:" + createBy);
|
||||
log.error("dutyUserId:" + dutyUserId);
|
||||
|
||||
String createByEmail = "";
|
||||
int beisenCreateUserId = -1;
|
||||
if(StringUtils.isNotBlank(createBy)){
|
||||
String jobnum = "";
|
||||
SimpleEmployee createByEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(createBy));
|
||||
if(createByEmployee !=null && createByEmployee.getId() > 0){
|
||||
jobnum = createByEmployee.getJobNum();
|
||||
createByEmail = createByEmployee.getEmail();
|
||||
}
|
||||
log.error("jobnum:" + jobnum);
|
||||
if(StringUtils.isNotBlank(jobnum)){
|
||||
String userid = beisenQueryUseridUtil.queryBeisenUserIdByJobNum(jobnum);
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
beisenCreateUserId = Integer.valueOf(userid);
|
||||
}
|
||||
log.error("beisenCreateUserId:" + beisenCreateUserId);
|
||||
}
|
||||
}
|
||||
log.error("createByEmail:" + createByEmail);
|
||||
|
||||
String dutyUserEmail = "";
|
||||
int beisenDutyUserId = -1;
|
||||
if(StringUtils.isNotBlank(dutyUserId)){
|
||||
String jobnum = "";
|
||||
SimpleEmployee dutyEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(dutyUserId));
|
||||
if(dutyEmployee !=null && dutyEmployee.getId() > 0){
|
||||
jobnum = dutyEmployee.getJobNum();
|
||||
dutyUserEmail = dutyEmployee.getEmail();
|
||||
}
|
||||
log.error("jobnum:" + jobnum);
|
||||
if(StringUtils.isNotBlank(jobnum)){
|
||||
String userid = beisenQueryUseridUtil.queryBeisenUserIdByJobNum(jobnum);
|
||||
if(StringUtils.isNotBlank(userid)){
|
||||
beisenDutyUserId = Integer.valueOf(userid);
|
||||
}
|
||||
log.error("beisenDutyUserId:" + beisenDutyUserId);
|
||||
}
|
||||
}
|
||||
log.error("dutyUserEmail:" + dutyUserEmail);
|
||||
|
||||
// String createByEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
// log.error("createByEmail:" + createByEmail);
|
||||
// String dutyUserEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
// log.error("dutyUserEmail:" + dutyUserEmail);
|
||||
|
||||
String originalCode = "";
|
||||
if(StringUtils.isNotBlank(originalId)){
|
||||
originalCode = hrmDepartmentDao.getDepartmentCodeById(originalId);
|
||||
}
|
||||
log.error("originalCode:" + originalCode);
|
||||
|
||||
int orgId = -1;
|
||||
if(StringUtils.isNotBlank(originalCode)){
|
||||
// BeisenDepartmentDto beisenDepartmentDto = beisenDeptInfoByOriginalIdUtil.getBeisenDeptDataByOriginalId(originalId);
|
||||
// log.error("beisenDepartmentDto:{}",beisenDepartmentDto.toString());
|
||||
String deptid = beisenQueryDeptIdUtil.queryBeisenDeptIdByCode(originalCode);
|
||||
if(StringUtils.isNotBlank(deptid)){
|
||||
orgId = Integer.valueOf(deptid);
|
||||
}
|
||||
// orgId = beisenDepartmentDto.getOrgId();
|
||||
}
|
||||
|
||||
String gzzz = String.valueOf(params.get("gzzz"));
|
||||
String rzzg = String.valueOf(params.get("rzzg"));
|
||||
log.error("rzzg:" + rzzg);
|
||||
log.error("orgId:" + orgId);
|
||||
|
||||
String dataId = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
|
||||
requestname,beisenCreateUserId,
|
||||
createDate,requirementCount,
|
||||
arivalTime,
|
||||
createByEmail,
|
||||
dutyUserEmail,
|
||||
orgId,
|
||||
salaryType,
|
||||
category,
|
||||
educationInfo,
|
||||
workExperience,
|
||||
kind,
|
||||
isSecrecy,
|
||||
originalCode,
|
||||
nlyq,
|
||||
zpgw,
|
||||
zwmc,
|
||||
beisenDutyUserId,
|
||||
xqmc,
|
||||
gzzz,
|
||||
rzzg,zxssyf,jjcd
|
||||
);
|
||||
|
||||
|
||||
log.error("dataId:" + dataId);
|
||||
// if(StringUtils.isNotBlank(dataId)){
|
||||
// String sourceType = "";
|
||||
// String groupId = "";
|
||||
//
|
||||
// String dataSql =" update uf_zpxqgl set bszxid = ? " +
|
||||
// " where form_data_id = ?\n" +
|
||||
// " and tenant_key=? \n" +
|
||||
// " and delete_type=0 \n" ;
|
||||
//
|
||||
// log.error("dataSql:" + dataSql);
|
||||
// List<String> paramList = new ArrayList<>(100);
|
||||
//
|
||||
// paramList.add(form_data_id);
|
||||
// paramList.add(Constants.TENANT_KEY);
|
||||
// List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
// result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
// }
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","创建招聘需求成功");
|
||||
actionMap.put("dataId",dataId);
|
||||
actionMap.put("form_data_id",form_data_id);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 转换为int
|
||||
* @param params
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public int converInteger(Map<String,Object> params,String key){
|
||||
int value = -1;
|
||||
try{
|
||||
String requirementStatusStr = (String) params.get(key);
|
||||
value = Integer.valueOf(requirementStatusStr);
|
||||
}catch (Exception e){
|
||||
log.error("key:{},e:{}",key,e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenJobRequirementUnRelateAction")
|
||||
public class Esb2BeisenJobRequirementUnRelateAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenJobRequirementUnRelateAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2BeisenUnRelateRequestUtil esb2BeisenUnRelateRequestUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String form_data_id = String.valueOf(params.get("form_data_id"));
|
||||
String requirementId = String.valueOf(params.get("requirementId"));
|
||||
|
||||
if(StringUtils.isBlank(requirementId)){
|
||||
return WeaResult.fail(500,"招聘需求信息获取为空");
|
||||
}
|
||||
|
||||
log.error("requirementId:" + requirementId);
|
||||
String code = esb2BeisenUnRelateRequestUtil.unRelateJobRequirement(requirementId);
|
||||
log.error("code:" + code);
|
||||
if(StringUtils.isBlank(code)){
|
||||
return WeaResult.fail(500,"取消招聘需求失败");
|
||||
}
|
||||
|
||||
if(!"200".equals(code)){
|
||||
return WeaResult.fail(500,"取消招聘需求失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","取消招聘需求成功");
|
||||
actionMap.put("datacode",code);
|
||||
actionMap.put("form_data_id",form_data_id);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Offer2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 废弃,由雪峰重写了
|
||||
*/
|
||||
@Service("Esb2BeisenOfferCronJob")
|
||||
public class Esb2BeisenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenOfferCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Offer2BeiSenUtil offer2BeiSenUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("EsbTrainingCronJobAction start");
|
||||
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
// String offerUrl = "/TenantBaseExternal/api/v5/Offer/GetByTimeWindow";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
JSONArray offerArray = new JSONArray();
|
||||
// LocalDate today = LocalDate.now();
|
||||
// LocalDate yesterday = today.minusDays(1);
|
||||
// String startDate = yesterday.toString();
|
||||
// String startTime = sdf.format(new Date());
|
||||
// String endDate = today.toString();
|
||||
// String endTime = sdf.format(new Date());
|
||||
|
||||
String startDate = String.valueOf(params.get("startDate"));
|
||||
String startTime = String.valueOf(params.get("startTime"));
|
||||
String endDate = String.valueOf(params.get("endDate"));
|
||||
String endTime = String.valueOf(params.get("endTime"));
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
offerArray = offer2BeiSenUtil.queryOfferByDateTime(token,startDate, startTime, endDate, endTime);
|
||||
}
|
||||
|
||||
log.error("offerArray:{}",offerArray.toJSONString());
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenOfferCronJob");
|
||||
actionMap.put("offer",offerArray);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Performance2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenPerformanceCronJob")
|
||||
public class Esb2BeisenPerformanceCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPerformanceCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Performance2BeiSenUtil performance2BeiSenUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2BeisenPerformanceCronJob start");
|
||||
|
||||
// String tokenUrl = "https://openapi.italent.cn/token";
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
//
|
||||
// String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
// String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
// int page = 0;
|
||||
// int capacity = 2;
|
||||
// int year = 2024;
|
||||
// int period = 8;
|
||||
|
||||
String page = String.valueOf(params.get("page")) ;
|
||||
String capacity = String.valueOf(params.get("capacity"));
|
||||
String year = String.valueOf(params.get("year"));
|
||||
String period = String.valueOf(params.get("period"));
|
||||
|
||||
// String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
// String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
// String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
JSONArray activityManagerArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
activityManagerArray = queryActivityManager(token,page,capacity,year,period);
|
||||
log.error("activityManagerArray:{}",activityManagerArray.toJSONString());
|
||||
queryAssessmentItem(activityManagerArray,token,page,capacity);
|
||||
assessmentArray = queryAssessment(activityManagerArray,token);
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenPerformanceCronJob");
|
||||
actionMap.put("assessmentArray",assessmentArray);
|
||||
actionMap.put("activityManagerArray",activityManagerArray);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public JSONArray queryActivityManager(String token,String page,String capacity,String year,String period){
|
||||
int activityTotal = 0;
|
||||
JSONArray activityManagerArray = new JSONArray();
|
||||
JSONArray performanceArray = new JSONArray();
|
||||
String bodyData = performance2BeiSenUtil.getActivityManagerCount(token,page,capacity,year,period);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("paging")){
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
activityTotal = pagingJson.getInteger("total");
|
||||
}
|
||||
if(dataObject.containsKey("items")){
|
||||
performanceArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(activityTotal <= Integer.valueOf(capacity)){
|
||||
activityManagerArray = performanceArray;
|
||||
}else{
|
||||
activityManagerArray.addAll(performanceArray);
|
||||
int pageCount = (int)Math.floor(activityTotal / Integer.valueOf(capacity));
|
||||
for(int i = 1; i < pageCount; i++){
|
||||
JSONArray itemArray = performance2BeiSenUtil.queryActivityManager(token,String.valueOf(i),capacity,year,period);
|
||||
activityManagerArray.addAll(itemArray);
|
||||
}
|
||||
}
|
||||
return activityManagerArray;
|
||||
}
|
||||
|
||||
public void queryAssessmentItem(JSONArray activityManagerArray,String token,String page,String capacity){
|
||||
|
||||
for(int i = 0; i < activityManagerArray.size(); i++){
|
||||
int itemTotal = 0;
|
||||
JSONArray itemsArray = new JSONArray();
|
||||
JSONArray assessmentItemArray = new JSONArray();
|
||||
String activityManagerId = activityManagerArray.getJSONObject(i).getString("id");
|
||||
log.error("activityManagerId:{}",activityManagerId);
|
||||
|
||||
if(StringUtils.isNotBlank(activityManagerId)){
|
||||
String bodyData = performance2BeiSenUtil.getAssessmentItemCount(token,page,capacity,activityManagerId);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("paging")){
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
itemTotal = pagingJson.getInteger("total");
|
||||
}
|
||||
if(dataObject.containsKey("items")){
|
||||
itemsArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("itemTotal:{}",itemTotal);
|
||||
if(itemTotal <= Integer.valueOf(capacity)){
|
||||
assessmentItemArray = itemsArray;
|
||||
}else{
|
||||
assessmentItemArray.addAll(itemsArray);
|
||||
int pageCount = (int)Math.floor(itemTotal / Integer.valueOf(capacity));
|
||||
for(int k = 1; k < pageCount; k++){
|
||||
log.error("K:{}",k);
|
||||
JSONArray itemArray = performance2BeiSenUtil.queryAssessmentItem(token,String.valueOf(k),capacity,activityManagerId);
|
||||
log.error("itemArray:{}",itemArray.size());
|
||||
assessmentItemArray.addAll(itemArray);
|
||||
}
|
||||
}
|
||||
log.error("JSONArray:{}",JSONArray.toJSONString(assessmentItemArray));
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param activityManagerArray
|
||||
* @param token
|
||||
*/
|
||||
public JSONArray queryAssessment(JSONArray activityManagerArray,String token){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
for(int i = 0; i < activityManagerArray.size(); i++) {
|
||||
String activityManagerId = activityManagerArray.getJSONObject(i).getString("id");
|
||||
log.error("activityManagerId:{}",activityManagerId);
|
||||
if (StringUtils.isNotBlank(activityManagerId)) {
|
||||
JSONArray itemsArray = performance2BeiSenUtil.queryAssessment(token,activityManagerId);
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,427 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmDepartmentDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmPerformanceDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenAssessmentUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service("Esb2BeisenPerformanceCronJobNew")
|
||||
public class Esb2BeisenPerformanceCronJobNew implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPerformanceCronJobNew.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenAssessmentUtil esb2BeiSenAssessmentUtil;
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
HrmDepartmentDao hrmDepartmentDao;
|
||||
|
||||
@Autowired
|
||||
HrmPerformanceDao hrmPerformanceDao;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenPerformanceCronJobNew start");
|
||||
int capacity = Integer.valueOf(String.valueOf(params.get("capacity")));
|
||||
String modifiedAfter = String.valueOf(params.get("modifiedAfter"));
|
||||
String modifiedBefore = String.valueOf(params.get("modifiedBefore"));
|
||||
|
||||
int page = 1;
|
||||
if(params.containsKey("page")){
|
||||
page = Integer.valueOf(String.valueOf(params.get("page")));
|
||||
}
|
||||
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
// String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
// String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
// String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("khnf");
|
||||
fieldList.add("khzq");
|
||||
fieldList.add("gh");
|
||||
fieldList.add("mc");
|
||||
fieldList.add("yx");
|
||||
fieldList.add("bm");
|
||||
fieldList.add("jxxbmmc");
|
||||
fieldList.add("jxhdmc");
|
||||
fieldList.add("zzdf");
|
||||
fieldList.add("jxxs");
|
||||
fieldList.add("bkhr");
|
||||
fieldList.add("khzqlx");
|
||||
fieldList.add("ppdj");
|
||||
fieldList.add("jxhdid");
|
||||
|
||||
fieldList.add("rzrq");
|
||||
fieldList.add("lzrq");
|
||||
fieldList.add("zzrq");
|
||||
fieldList.add("ryzt");
|
||||
fieldList.add("gs");
|
||||
fieldList.add("bm1");
|
||||
fieldList.add("bm2");
|
||||
fieldList.add("bm3");
|
||||
fieldList.add("bm4");
|
||||
fieldList.add("gzdd");
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
JSONArray assessmentArray = getAssessmentArray(token,page, capacity, modifiedAfter, modifiedBefore);
|
||||
log.error("assessmentArray:"+assessmentArray.size());
|
||||
// if(StringUtils.isNotBlank(token)){
|
||||
// int total = 0;
|
||||
// JSONArray itemArray = new JSONArray();
|
||||
// String bodyData = esb2BeiSenAssessmentUtil.getAssessmentsByFilters(token, page, capacity, modifiedAfter, modifiedBefore);
|
||||
// if(StringUtils.isNotBlank(bodyData)){
|
||||
// JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
// if(bodyJson.containsKey("code")){
|
||||
// JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
// if(dataObject.containsKey("paging")){
|
||||
// JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
// total = pagingJson.getInteger("total");
|
||||
// }
|
||||
// if(dataObject.containsKey("items")){
|
||||
// itemArray = dataObject.getJSONArray("items");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// log.error("itemArray:"+itemArray.size());
|
||||
//
|
||||
// if(total <= capacity){
|
||||
// assessmentArray.addAll(itemArray) ;
|
||||
// }else{
|
||||
// assessmentArray.addAll(itemArray);
|
||||
// int pageCount = (int)Math.floor(total/(capacity*1.0));
|
||||
// log.error("pageCount:"+pageCount);
|
||||
// for(int i = 1; i < pageCount; i++){
|
||||
// int page2 = i+1;
|
||||
// JSONArray itemArray2 = esb2BeiSenAssessmentUtil.queryAssessmentsByPage(token,page2,capacity,modifiedAfter, modifiedBefore);
|
||||
// assessmentArray.add(itemArray2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
int effectiveTotal = 0;
|
||||
int failTotal = 0;
|
||||
|
||||
if(assessmentArray.size() > 0){
|
||||
JSONArray dataArray = convertAssessmentList(assessmentArray);
|
||||
log.error("dataArray:"+dataArray.size());
|
||||
|
||||
Map<String, Object> fieldMap = hrmFormFieldDao.queryFromTableField(Constants.assessmentFormTable,fieldList);
|
||||
|
||||
List<EBDataReqDto> addDatas = new ArrayList<EBDataReqDto>();
|
||||
List<EBDataReqDto> updateDatas = new ArrayList<EBDataReqDto>();
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("bkhr") && StringUtils.isNotBlank(dataJson.getString("bkhr"))){
|
||||
String khnf = dataJson.getString("khnf");
|
||||
String khzq = dataJson.getString("khzq");
|
||||
String bkhr = dataJson.getString("bkhr");
|
||||
String jxhdid = dataJson.getString("jxhdid");
|
||||
String ufId = hrmPerformanceDao.getAssessmentData(khnf,khzq,jxhdid,bkhr);
|
||||
log.error("ufId:{}",ufId);
|
||||
|
||||
String zzdf = dataJson.getString("zzdf");
|
||||
log.error("zzdf:{}",zzdf);
|
||||
|
||||
if(StringUtils.isNotBlank(ufId)){
|
||||
log.error("修改");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
mainData.add(new EBDataReqDetailDto("id", ufId));
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
effectiveTotal++;
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
updateDatas.add(ebDataReqDto);
|
||||
}else{
|
||||
log.error("新增");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
effectiveTotal++;
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
addDatas.add(ebDataReqDto);
|
||||
}
|
||||
}else{
|
||||
failTotal++;
|
||||
}
|
||||
}
|
||||
log.error("addDatas:{}",addDatas.size());
|
||||
log.error("updateDatas:{}",updateDatas.size());
|
||||
|
||||
Map<String,Object> recordMap = hrmFormFieldDao.queryTableFormId(Constants.assessmentFormTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
if(addDatas.size() > 0){
|
||||
EBDataChangeResult addEbDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(addDatas,formId,appId);
|
||||
boolean isTrue = addEbDataChangeResult.getStatus();
|
||||
log.error("message:{}",addEbDataChangeResult.getMessage());
|
||||
log.error("isTrue1:{}",isTrue);
|
||||
if(isTrue){
|
||||
ebList.addAll(addEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
|
||||
if(updateDatas.size() > 0){
|
||||
|
||||
EBDataChangeResult updateEbDataChangeResult = ebuilderOperateUtils.bacthEditEbForm(updateDatas,formId,appId);
|
||||
boolean isTrue = updateEbDataChangeResult.getStatus();
|
||||
log.error("isTrue2:{}",isTrue);
|
||||
log.error("message2:{}",updateEbDataChangeResult.getMessage());
|
||||
if(isTrue){
|
||||
ebList.addAll(updateEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String ebId:ebList){
|
||||
|
||||
String rylb = "";
|
||||
String bm1 = "";
|
||||
if("2".equals(rylb)){
|
||||
|
||||
}else if("".equals(bm1)){
|
||||
|
||||
}
|
||||
}
|
||||
log.error("ebList:{}", JSON.toJSONString(ebList));
|
||||
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
actionMap.put("total",assessmentArray.size());
|
||||
actionMap.put("effectiveTotal",effectiveTotal);
|
||||
actionMap.put("failTotal",failTotal);
|
||||
actionMap.put("ebTotal",ebList.size());
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param modifiedAfter
|
||||
* @param modifiedBefore
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getAssessmentArray(String token,int page, int capacity, String modifiedAfter, String modifiedBefore) {
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
int total = 0;
|
||||
JSONArray itemArray = new JSONArray();
|
||||
String bodyData = esb2BeiSenAssessmentUtil.getAssessmentsByFilters(token, page, capacity, modifiedAfter, modifiedBefore);
|
||||
if (StringUtils.isNotBlank(bodyData)) {
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if (bodyJson.containsKey("code")) {
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if (dataObject.containsKey("paging")) {
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
total = pagingJson.getInteger("total");
|
||||
}
|
||||
if (dataObject.containsKey("items")) {
|
||||
itemArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.error("itemArray:" + itemArray.size());
|
||||
|
||||
if (total <= capacity) {
|
||||
assessmentArray.addAll(itemArray);
|
||||
} else {
|
||||
assessmentArray.addAll(itemArray);
|
||||
int pageCount = (int) Math.floor(total / (capacity * 1.0));
|
||||
log.error("pageCount:" + pageCount);
|
||||
for (int i = 1; i < pageCount; i++) {
|
||||
int page2 = i + 1;
|
||||
JSONArray itemArray2 = esb2BeiSenAssessmentUtil.queryAssessmentsByPage(token, page2, capacity, modifiedAfter, modifiedBefore);
|
||||
assessmentArray.addAll(itemArray2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param assessmentArray
|
||||
* @return
|
||||
*/
|
||||
public JSONArray convertAssessmentList(JSONArray assessmentArray) {
|
||||
|
||||
JSONArray dataArray = new JSONArray();
|
||||
Map<String,Object> departmentMap = hrmDepartmentDao.queryDepartmentData();
|
||||
Map<String,Object> employeeMap = hrmDepartmentDao.queryEmployeeData();
|
||||
log.error("departmentMap:"+departmentMap.size());
|
||||
log.error("employeeMap:"+employeeMap.size());
|
||||
|
||||
|
||||
for(int i=0;i<assessmentArray.size();i++) {
|
||||
JSONObject assessmentJson = assessmentArray.getJSONObject(i);
|
||||
String id = assessmentJson.getString("id");
|
||||
JSONArray fieldDatas = assessmentJson.getJSONArray("fieldDatas");
|
||||
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("bsjxid",id);
|
||||
|
||||
|
||||
|
||||
for(int n=0;n<fieldDatas.size();n++){
|
||||
JSONObject fieldDataJson = fieldDatas.getJSONObject(n);
|
||||
log.error("fieldDataJson:{}",fieldDataJson.toJSONString());
|
||||
|
||||
String name = fieldDataJson.getString("name");
|
||||
String value = fieldDataJson.getString("value");
|
||||
String text = fieldDataJson.getString("text");
|
||||
|
||||
if("ActivityManagerId".equals(name)){
|
||||
dataJson.put("jxhdmc",text);
|
||||
dataJson.put("jxhdid",value);
|
||||
}
|
||||
|
||||
// if("Employee".equals(name)){
|
||||
// dataJson.put("jxhdmc",value);
|
||||
// }
|
||||
// if("DeptId".equals(name)){
|
||||
// dataJson.put("jxhdmc",value);
|
||||
// }
|
||||
|
||||
if("Year".equals(name)){
|
||||
dataJson.put("khnf",value);
|
||||
}
|
||||
if("Period".equals(name)){
|
||||
dataJson.put("khzq",value);
|
||||
|
||||
if("-1".equals(value)){
|
||||
dataJson.put("khzqlx","4"); //年度考核
|
||||
}else if("1".equals(value) || "2".equals(value)
|
||||
|| "3".equals(value)
|
||||
|| "4".equals(value)
|
||||
|| "5".equals(value)
|
||||
|| "6".equals(value)
|
||||
|| "7".equals(value)
|
||||
|| "8".equals(value)
|
||||
|| "9".equals(value)
|
||||
|| "10".equals(value)
|
||||
|| "11".equals(value)
|
||||
|| "12".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","1"); //月度考核
|
||||
}else if("31".equals(value) || "22".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","3"); //半年度考核
|
||||
}else if("21".equals(value) || "22".equals(value) || "23".equals(value) || "24".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","2"); //季度考核
|
||||
}
|
||||
}
|
||||
|
||||
if("Name".equals(name)){
|
||||
dataJson.put("mc",value);
|
||||
}
|
||||
|
||||
if("Email".equals(name)){
|
||||
dataJson.put("yx",value);
|
||||
}
|
||||
|
||||
if("StaffCode".equals(name)){
|
||||
dataJson.put("gh",value);
|
||||
log.error("gh:{}",value);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(employeeMap.containsKey(value)){
|
||||
String employeeid = String.valueOf(employeeMap.get(value));
|
||||
log.error("employeeid:{}",employeeid);
|
||||
dataJson.put("bkhr",employeeid);
|
||||
if(StringUtils.isNotBlank(employeeid)){
|
||||
Map<String,Object> otherMap = hrmPerformanceDao.queryEmployeeAssessmentOtherInfo(employeeid);
|
||||
Iterator<Map.Entry<String, Object>> iterator = otherMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Object> entry = iterator.next();
|
||||
String emKey = entry.getKey();
|
||||
String emValue = entry.getValue().toString();
|
||||
log.error("emKey:{}",emKey);
|
||||
log.error("emValue:{}",emValue);
|
||||
dataJson.put(emKey,emValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if("StaffDep".equals(name)){
|
||||
dataJson.put("jxxbmmc",text);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(departmentMap.containsKey(value)){
|
||||
String departmentid = String.valueOf(departmentMap.get(value));
|
||||
dataJson.put("bm",departmentid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if("FinalScore".equals(name)){
|
||||
dataJson.put("zzdf",value);
|
||||
}
|
||||
|
||||
if("TotalScoreRuleIdLookup".equals(name)){
|
||||
dataJson.put("ppdj",text);
|
||||
}
|
||||
|
||||
}
|
||||
dataArray.add(dataJson);
|
||||
log.error("dataJson:{}",dataJson.toJSONString());
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmBeisenPositionDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenPositionUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service("Esb2BeisenPositionFullCronJob")
|
||||
public class Esb2BeisenPositionFullCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPositionFullCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenPositionUtil esb2BeiSenPositionUtil;
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
|
||||
@Autowired
|
||||
HrmBeisenPositionDao hrmBeisenPositionDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2BeisenPositionFullCronJob");
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
JSONArray positionArray = new JSONArray();
|
||||
|
||||
String startDate = String.valueOf(params.get("startDate"));
|
||||
String endDate = String.valueOf(params.get("endDate"));
|
||||
int capacity = 100;
|
||||
int total = 0;
|
||||
String scrollId = "";
|
||||
JSONArray firstArray = new JSONArray();
|
||||
String msg = esb2BeiSenPositionUtil.queryPositionByDate(startDate, endDate,capacity);
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject msgJson = JSONObject.parseObject(msg);
|
||||
if(msgJson.containsKey("total")){
|
||||
total = msgJson.getInteger("total");
|
||||
}
|
||||
if(msgJson.containsKey("data")){
|
||||
firstArray = msgJson.getJSONArray("data");
|
||||
}
|
||||
|
||||
if(msgJson.containsKey("scrollId")){
|
||||
scrollId = msgJson.getString("scrollId");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("total:{}",total);
|
||||
log.error("firstArray:{}",firstArray.size());
|
||||
log.error("scrollId:{}",scrollId);
|
||||
|
||||
if(total <= capacity){
|
||||
positionArray = firstArray;
|
||||
}else{
|
||||
if(firstArray.size() > 0){
|
||||
positionArray.addAll(firstArray);
|
||||
}
|
||||
int pageCount = (int)Math.floor(total / capacity*1.0);
|
||||
log.error("pageCount:{}",pageCount);
|
||||
int count = 0;
|
||||
while(StringUtils.isNotBlank(scrollId) && !"null".equals(scrollId)){
|
||||
String positionData = esb2BeiSenPositionUtil.queryPositionByscrollId(startDate, endDate,scrollId,capacity);
|
||||
if(StringUtils.isNotBlank(positionData)){
|
||||
JSONObject msgJson = JSONObject.parseObject(positionData);
|
||||
|
||||
if(msgJson.containsKey("data")){
|
||||
JSONArray itemArray = msgJson.getJSONArray("data");
|
||||
log.error("itemArray:{}",itemArray.size());
|
||||
if(itemArray.size() > 0){
|
||||
positionArray.addAll(itemArray);
|
||||
}else{
|
||||
scrollId = "";
|
||||
}
|
||||
}
|
||||
|
||||
if(msgJson.containsKey("scrollId")){
|
||||
scrollId = msgJson.getString("scrollId");
|
||||
}else{
|
||||
scrollId = "";
|
||||
}
|
||||
}else{
|
||||
scrollId = "";
|
||||
}
|
||||
|
||||
log.error("scrollId:{}",scrollId);
|
||||
log.error("count:{}",count);
|
||||
|
||||
count++;
|
||||
if(count > (pageCount+5)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("positionArray:{}",positionArray.size());
|
||||
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("bs_gwid");
|
||||
fieldList.add("bs_gwmc");
|
||||
fieldList.add("bs_gwbm");
|
||||
|
||||
if(positionArray.size() > 0){
|
||||
updateHrmPosition(positionArray);
|
||||
doSavePositionData(positionArray);
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public JSONArray convertPositionList(JSONArray positionArray){
|
||||
JSONArray dataArray = new JSONArray();
|
||||
|
||||
for(int i=0;i<positionArray.size();i++) {
|
||||
JSONObject positionJson = positionArray.getJSONObject(i);
|
||||
String name = positionJson.getString("name");
|
||||
String code = positionJson.getString("code");
|
||||
String objectId = positionJson.getString("objectId");
|
||||
|
||||
log.error("name:{}",name);
|
||||
log.error("objectId:{}",objectId);
|
||||
|
||||
if(StringUtils.isNotBlank(code) && StringUtils.isNotBlank(objectId)){
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("bs_gwid",objectId);
|
||||
dataJson.put("bs_gwmc",name);
|
||||
dataJson.put("bs_gwbm",code);
|
||||
dataArray.add(dataJson);
|
||||
}
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
public List<String> doSavePositionData(JSONArray positionArray){
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("bs_gwid");
|
||||
fieldList.add("bs_gwmc");
|
||||
fieldList.add("bs_gwbm");
|
||||
|
||||
if(positionArray.size() > 0){
|
||||
JSONArray dataArray = convertPositionList(positionArray);
|
||||
log.error("dataArray:"+dataArray.size());
|
||||
Map<String, Object> fieldMap = hrmFormFieldDao.queryFromTableField(Constants.beisenPostionTable,fieldList);
|
||||
List<EBDataReqDto> addDatas = new ArrayList<EBDataReqDto>();
|
||||
List<EBDataReqDto> updateDatas = new ArrayList<EBDataReqDto>();
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("bs_gwid") && StringUtils.isNotBlank(dataJson.getString("bs_gwid"))){
|
||||
String bs_gwid = dataJson.getString("bs_gwid");
|
||||
String bs_gwmc = dataJson.getString("bs_gwmc");
|
||||
String bs_gwbm = dataJson.getString("bs_gwbm");
|
||||
String ufId = hrmBeisenPositionDao.getPositionIdByGwId(bs_gwid);
|
||||
log.error("ufId:{}",ufId);
|
||||
|
||||
if(StringUtils.isNotBlank(ufId)){
|
||||
log.error("修改");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
mainData.add(new EBDataReqDetailDto("id", ufId));
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
updateDatas.add(ebDataReqDto);
|
||||
}else{
|
||||
log.error("新增");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
addDatas.add(ebDataReqDto);
|
||||
}
|
||||
}else{
|
||||
}
|
||||
}
|
||||
log.error("addDatas:{}",addDatas.size());
|
||||
log.error("updateDatas:{}",updateDatas.size());
|
||||
|
||||
Map<String,Object> recordMap = hrmFormFieldDao.queryTableFormId(Constants.beisenPostionTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
if(addDatas.size() > 0){
|
||||
EBDataChangeResult addEbDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(addDatas,formId,appId);
|
||||
boolean isTrue = addEbDataChangeResult.getStatus();
|
||||
log.error("message:{}",addEbDataChangeResult.getMessage());
|
||||
log.error("isTrue1:{}",isTrue);
|
||||
if(isTrue){
|
||||
ebList.addAll(addEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
|
||||
if(updateDatas.size() > 0){
|
||||
|
||||
EBDataChangeResult updateEbDataChangeResult = ebuilderOperateUtils.bacthEditEbForm(updateDatas,formId,appId);
|
||||
boolean isTrue = updateEbDataChangeResult.getStatus();
|
||||
log.error("isTrue2:{}",isTrue);
|
||||
log.error("message2:{}",updateEbDataChangeResult.getMessage());
|
||||
if(isTrue){
|
||||
ebList.addAll(updateEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ebList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> updateHrmPosition(JSONArray positionArray){
|
||||
Map<String,String> resultMap = new HashMap<String,String>();
|
||||
int failCount = 0;
|
||||
int successCount = 0;
|
||||
int total = positionArray.size() ;
|
||||
if(positionArray.size() > 0){
|
||||
for(int i=0;i<positionArray.size();i++){
|
||||
JSONObject dataJson = positionArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("objectId") && StringUtils.isNotBlank(dataJson.getString("objectId"))){
|
||||
String objectId = dataJson.getString("objectId");
|
||||
String code = dataJson.getString("code");
|
||||
String oIdOrganization = dataJson.getString("oIdOrganization");
|
||||
Map<String, Object> result = hrmBeisenPositionDao.updateHrmPositionByBensen(code,objectId,oIdOrganization);
|
||||
if (result.containsKey("code")) {
|
||||
code = String.valueOf(result.get("code"));
|
||||
log.error("code:" + code);
|
||||
if ("200".equals(code)) {
|
||||
successCount++;
|
||||
}else{
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("failCount",String.valueOf(failCount));
|
||||
resultMap.put("successCount",String.valueOf(successCount));
|
||||
resultMap.put("total",String.valueOf(total));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmFormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmBeisenPositionDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenPositionUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenPositionTimeCronJob")
|
||||
public class Esb2BeisenPositionTimeCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPositionTimeCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenPositionUtil esb2BeiSenPositionUtil;
|
||||
|
||||
@Autowired
|
||||
HrmFormFieldDao hrmFormFieldDao;
|
||||
|
||||
@Autowired
|
||||
HrmBeisenPositionDao hrmBeisenPositionDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
JSONArray positionArray = new JSONArray();
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
// 获取当前日期
|
||||
LocalDate today = LocalDate.now();
|
||||
// 获取当前日期的前一周
|
||||
LocalDate lastWeek = today.minusWeeks(1);
|
||||
|
||||
String startDate = lastWeek.toString();
|
||||
String endDate = today.toString();
|
||||
|
||||
log.error("startDate:{}",startDate);
|
||||
log.error("endDate:{}",endDate);
|
||||
|
||||
int capacity = 100;
|
||||
int total = 0;
|
||||
String scrollId = "";
|
||||
JSONArray firstArray = new JSONArray();
|
||||
String msg = esb2BeiSenPositionUtil.queryPositionByDate(startDate, endDate,capacity);
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject msgJson = JSONObject.parseObject(msg);
|
||||
if(msgJson.containsKey("total")){
|
||||
total = msgJson.getInteger("total");
|
||||
}
|
||||
if(msgJson.containsKey("data")){
|
||||
firstArray = msgJson.getJSONArray("data");
|
||||
}
|
||||
|
||||
if(msgJson.containsKey("scrollId")){
|
||||
scrollId = msgJson.getString("scrollId");
|
||||
}
|
||||
}
|
||||
|
||||
if(total <= capacity){
|
||||
positionArray = firstArray;
|
||||
}else{
|
||||
if(firstArray.size() > 0){
|
||||
positionArray.addAll(firstArray);
|
||||
}
|
||||
int pageCount = (int)Math.floor(total / capacity*1.0);
|
||||
int count = 0;
|
||||
while(StringUtils.isNotBlank(scrollId) && !"null".equals(scrollId)){
|
||||
String positionData = esb2BeiSenPositionUtil.queryPositionByscrollId(startDate, endDate,scrollId,capacity);
|
||||
if(StringUtils.isNotBlank(positionData)){
|
||||
JSONObject msgJson = JSONObject.parseObject(positionData);
|
||||
|
||||
if(msgJson.containsKey("data")){
|
||||
JSONArray itemArray = msgJson.getJSONArray("data");
|
||||
if(itemArray.size() > 0){
|
||||
positionArray.add(itemArray);
|
||||
}
|
||||
}
|
||||
if(msgJson.containsKey("scrollId")){
|
||||
scrollId = msgJson.getString("scrollId");
|
||||
}else{
|
||||
scrollId = "";
|
||||
}
|
||||
}else{
|
||||
scrollId = "";
|
||||
}
|
||||
count++;
|
||||
if(count > (pageCount+5)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("positionArray:{}",positionArray.size());
|
||||
|
||||
if(positionArray.size() > 0){
|
||||
updateHrmPosition(positionArray);
|
||||
doSavePositionData(positionArray);
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
actionMap.put("total",ebList.size());
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public JSONArray convertPositionList(JSONArray positionArray){
|
||||
JSONArray dataArray = new JSONArray();
|
||||
for(int i=0;i<positionArray.size();i++) {
|
||||
JSONObject positionJson = positionArray.getJSONObject(i);
|
||||
String name = positionJson.getString("name");
|
||||
String code = positionJson.getString("code");
|
||||
String objectId = positionJson.getString("objectId");
|
||||
|
||||
if(StringUtils.isNotBlank(code) && StringUtils.isNotBlank(objectId)){
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("bs_gwid",objectId);
|
||||
dataJson.put("bs_gwmc",name);
|
||||
dataJson.put("bs_gwbm",code);
|
||||
dataArray.add(dataJson);
|
||||
}
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 保存职位数据
|
||||
* @param positionArray
|
||||
* @return
|
||||
*/
|
||||
public List<String> doSavePositionData(JSONArray positionArray){
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("bs_gwid");
|
||||
fieldList.add("bs_gwmc");
|
||||
fieldList.add("bs_gwbm");
|
||||
|
||||
if(positionArray.size() > 0){
|
||||
JSONArray dataArray = convertPositionList(positionArray);
|
||||
log.error("dataArray:"+dataArray.size());
|
||||
Map<String, Object> fieldMap = hrmFormFieldDao.queryFromTableField(Constants.beisenPostionTable,fieldList);
|
||||
List<EBDataReqDto> addDatas = new ArrayList<EBDataReqDto>();
|
||||
List<EBDataReqDto> updateDatas = new ArrayList<EBDataReqDto>();
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("bs_gwid") && StringUtils.isNotBlank(dataJson.getString("bs_gwid"))){
|
||||
String bs_gwid = dataJson.getString("bs_gwid");
|
||||
String bs_gwmc = dataJson.getString("bs_gwmc");
|
||||
String bs_gwbm = dataJson.getString("bs_gwbm");
|
||||
String ufId = hrmBeisenPositionDao.getPositionIdByGwId(bs_gwid);
|
||||
log.error("ufId:{}",ufId);
|
||||
|
||||
if(StringUtils.isNotBlank(ufId)){
|
||||
log.error("修改");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
mainData.add(new EBDataReqDetailDto("id", ufId));
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
updateDatas.add(ebDataReqDto);
|
||||
}else{
|
||||
log.error("新增");
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
addDatas.add(ebDataReqDto);
|
||||
}
|
||||
}else{
|
||||
}
|
||||
}
|
||||
log.error("addDatas:{}",addDatas.size());
|
||||
log.error("updateDatas:{}",updateDatas.size());
|
||||
|
||||
Map<String,Object> recordMap = hrmFormFieldDao.queryTableFormId(Constants.beisenPostionTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
if(addDatas.size() > 0){
|
||||
EBDataChangeResult addEbDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(addDatas,formId,appId);
|
||||
boolean isTrue = addEbDataChangeResult.getStatus();
|
||||
log.error("message:{}",addEbDataChangeResult.getMessage());
|
||||
log.error("isTrue1:{}",isTrue);
|
||||
if(isTrue){
|
||||
ebList.addAll(addEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
|
||||
if(updateDatas.size() > 0){
|
||||
|
||||
EBDataChangeResult updateEbDataChangeResult = ebuilderOperateUtils.bacthEditEbForm(updateDatas,formId,appId);
|
||||
boolean isTrue = updateEbDataChangeResult.getStatus();
|
||||
log.error("isTrue2:{}",isTrue);
|
||||
log.error("message2:{}",updateEbDataChangeResult.getMessage());
|
||||
if(isTrue){
|
||||
ebList.addAll(updateEbDataChangeResult.getDataIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ebList;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> updateHrmPosition(JSONArray positionArray){
|
||||
Map<String,String> resultMap = new HashMap<String,String>();
|
||||
int failCount = 0;
|
||||
int successCount = 0;
|
||||
int total = positionArray.size() ;
|
||||
if(positionArray.size() > 0){
|
||||
for(int i=0;i<positionArray.size();i++){
|
||||
JSONObject dataJson = positionArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("objectId") && StringUtils.isNotBlank(dataJson.getString("objectId"))){
|
||||
String objectId = dataJson.getString("objectId");
|
||||
String code = dataJson.getString("code");
|
||||
String oIdOrganization = dataJson.getString("oIdOrganization");
|
||||
Map<String, Object> result = hrmBeisenPositionDao.updateHrmPositionByBensen(code,objectId,oIdOrganization);
|
||||
if (result.containsKey("code")) {
|
||||
code = String.valueOf(result.get("code"));
|
||||
log.error("code:" + code);
|
||||
if ("200".equals(code)) {
|
||||
successCount++;
|
||||
}else{
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("failCount",String.valueOf(failCount));
|
||||
resultMap.put("successCount",String.valueOf(successCount));
|
||||
resultMap.put("total",String.valueOf(total));
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.module;
|
||||
|
||||
/**
|
||||
* 缓存moduleKey
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
|
||||
public class BeisenTokenModuleKey {
|
||||
//datacenter
|
||||
public final static String BENSENTOKEN_DATACENTER = "BENSENTOKEN_DATACENTER";
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface ConversionResignService {
|
||||
|
||||
Map<String,Object> resignConversion(Map<String,Object> paraMap);
|
||||
|
||||
Map<String,Object> resignConversion2(Map<String,Object> paraMap);
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.service.impl;
|
||||
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.ConversionResignDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class ConversionResignServiceImpl implements ConversionResignService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConversionResignServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ConversionResignDao conversionResignDao;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> resignConversion(Map<String, Object> paraMap) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String conversionDay = "";
|
||||
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Long employeeId = Long.valueOf(String.valueOf(paraMap.get("employeeId")));
|
||||
String lzrq = (String) paraMap.get("lzrq");
|
||||
log.error("employeeId:"+employeeId);
|
||||
log.error("lzrq:{}",lzrq);
|
||||
|
||||
String hiredate = "";
|
||||
if(employeeId > 0){
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
hiredate = sdf.format(simpleEmployee.getHiredate());
|
||||
}
|
||||
log.error("hiredate:{}",hiredate);
|
||||
|
||||
|
||||
dataMap.put("employeeid",employeeId);
|
||||
dataMap.put("lzrq",lzrq);
|
||||
dataMap.put("rzrq",hiredate);
|
||||
|
||||
if(StringUtils.isNotBlank(lzrq) && StringUtils.isNotBlank(hiredate)){
|
||||
String rznf = hiredate.substring(0,4);
|
||||
String lznf = lzrq.substring(0,4);
|
||||
|
||||
log.error("rznf:"+rznf);
|
||||
log.error("lznf:"+lznf);
|
||||
|
||||
if(StringUtils.isNotBlank(rznf) && StringUtils.isNotBlank(lznf) ){
|
||||
double annualBase = conversionResignDao.queryEmployeeAnnualLeave(String.valueOf(employeeId),lznf);
|
||||
|
||||
log.error("annualBase:"+annualBase);
|
||||
|
||||
dataMap.put("annualBase",annualBase+"");
|
||||
if(rznf.equals(lznf)){
|
||||
LocalDate rzDate = LocalDate.parse(hiredate, formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(lzDate, rzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}else{
|
||||
LocalDate rzDate = LocalDate.parse(lznf+"-01-01", formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(lzDate, rzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap.put("days",conversionDay);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> resignConversion2(Map<String, Object> paraMap) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String conversionDay = "";
|
||||
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Long employeeId = Long.valueOf(String.valueOf(paraMap.get("employeeId")));
|
||||
String lzrq = (String) paraMap.get("lzrq");
|
||||
log.error("employeeId:"+employeeId);
|
||||
log.error("lzrq:"+lzrq);
|
||||
|
||||
String hiredate = "";
|
||||
if(employeeId > 0){
|
||||
hiredate = conversionResignDao.queryEmployeeById(String.valueOf(employeeId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(hiredate)){
|
||||
hiredate = hiredate.substring(0,10);
|
||||
}
|
||||
log.error("hiredate:"+hiredate);
|
||||
|
||||
dataMap.put("employeeid",employeeId);
|
||||
dataMap.put("lzrq",lzrq);
|
||||
dataMap.put("rzrq",hiredate);
|
||||
|
||||
if(StringUtils.isNotBlank(lzrq) && StringUtils.isNotBlank(hiredate)){
|
||||
|
||||
String rznf = hiredate.substring(0,4);
|
||||
String lznf = lzrq.substring(0,4);
|
||||
|
||||
log.error("rznf:"+rznf);
|
||||
log.error("lznf:"+lznf);
|
||||
|
||||
if(StringUtils.isNotBlank(rznf) && StringUtils.isNotBlank(lznf) ){
|
||||
double annualBase = conversionResignDao.queryEmployeeAnnualLeave(String.valueOf(employeeId),lznf);
|
||||
|
||||
log.error("annualBase:"+annualBase);
|
||||
|
||||
dataMap.put("annualBase",annualBase+"");
|
||||
if(rznf.equals(lznf)){
|
||||
LocalDate rzDate = LocalDate.parse(hiredate, formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(rzDate,lzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}else{
|
||||
LocalDate rzDate = LocalDate.parse(lznf+"-01-01", formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(rzDate,lzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap.put("days",conversionDay);
|
||||
return dataMap;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffPositionDto;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenDepartmentInfoByOriginalIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenDepartmentInfoByOriginalIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenStaffDto getBeisenDeptDataByOriginalId(String staffcode){
|
||||
BeisenStaffDto beisenStaffDto = new BeisenStaffDto();
|
||||
if(StringUtils.isEmpty(staffcode)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryUserInfoByStaffCode(token,staffcode);
|
||||
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
|
||||
if(itemObject.containsKey("staffDto")){
|
||||
JSONObject staffDto = itemObject.getJSONObject("staffDto");
|
||||
beisenStaffDto.setDepartmentId(staffDto.getString("departmentId"));
|
||||
beisenStaffDto.setDepartmentName(staffDto.getString("departmentName"));
|
||||
String employedDate = staffDto.getString("employedDate");
|
||||
|
||||
if(!"null".equals(employedDate) && employedDate !=null ){
|
||||
if(employedDate.contains("T")){
|
||||
employedDate = employedDate.substring(0,employedDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setEmployedDate(employedDate);
|
||||
|
||||
beisenStaffDto.setJobCode(staffDto.getString("jobCode"));
|
||||
beisenStaffDto.setPositionName(staffDto.getString("positionName"));
|
||||
beisenStaffDto.setLineManagerId(staffDto.getString("lineManagerId"));
|
||||
beisenStaffDto.setStaffCode(staffDto.getString("staffCode"));
|
||||
beisenStaffDto.setStaffStatus(staffDto.getString("staffStatus"));
|
||||
beisenStaffDto.setIsDelete(staffDto.getString("isDelete"));
|
||||
String useridStr = staffDto.getString("userId");
|
||||
int userid = -1 ;
|
||||
if(StringUtils.isNotBlank(useridStr)){
|
||||
try{
|
||||
userid = Integer.valueOf(useridStr);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
beisenStaffDto.setUserId(userid);
|
||||
|
||||
beisenStaffDto.setTenantId(staffDto.getString("tenantId"));
|
||||
beisenStaffDto.setEmail(staffDto.getString("email"));
|
||||
beisenStaffDto.setUserType(staffDto.getString("userType"));
|
||||
beisenStaffDto.setUserStatus(staffDto.getString("userStatus"));
|
||||
beisenStaffDto.setOrigin(staffDto.getString("origin"));
|
||||
beisenStaffDto.setOriginalId(staffDto.getString("originalId"));
|
||||
beisenStaffDto.setName(staffDto.getString("name"));
|
||||
beisenStaffDto.setEnglishName(staffDto.getString("englishName"));
|
||||
beisenStaffDto.setSex(staffDto.getString("sex"));
|
||||
String birthday = staffDto.getString("birthday");
|
||||
|
||||
if(!"null".equals(birthday) && birthday !=null ){
|
||||
if(birthday.contains("T")){
|
||||
birthday = birthday.substring(0,birthday.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
beisenStaffDto.setBirthday(birthday);
|
||||
beisenStaffDto.setMobile(staffDto.getString("mobile"));
|
||||
beisenStaffDto.setIdCardType(staffDto.getString("idCardType"));
|
||||
|
||||
String graduateDate = staffDto.getString("graduateDate");
|
||||
if(!"null".equals(graduateDate) && graduateDate !=null ){
|
||||
if(graduateDate.contains("T")){
|
||||
graduateDate = graduateDate.substring(0,graduateDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
beisenStaffDto.setGraduateDate(graduateDate);
|
||||
|
||||
beisenStaffDto.setNativePlace(staffDto.getString("nativePlace"));
|
||||
String beganWorkDate = staffDto.getString("beganWorkDate");
|
||||
if(!"null".equals(beganWorkDate) && beganWorkDate !=null ){
|
||||
if(beganWorkDate.contains("T")){
|
||||
beganWorkDate = beganWorkDate.substring(0,beganWorkDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setBeganWorkDate(beganWorkDate);
|
||||
beisenStaffDto.setGraduateFrom(staffDto.getString("graduateFrom"));
|
||||
beisenStaffDto.setMajor(staffDto.getString("major"));
|
||||
beisenStaffDto.setPositionCategory(staffDto.getString("positionCategory"));
|
||||
}
|
||||
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto = new BeisenStaffDepartmentDto();
|
||||
if(itemObject.containsKey("departmentDto")){
|
||||
JSONObject departmentDto = itemObject.getJSONObject("departmentDto");
|
||||
beisenStaffDepartmentDto.setId(departmentDto.getString("id"));
|
||||
beisenStaffDepartmentDto.setName(departmentDto.getString("name"));
|
||||
beisenStaffDepartmentDto.setCode(departmentDto.getString("code"));
|
||||
beisenStaffDepartmentDto.setAbbreviation(departmentDto.getString("abbreviation"));
|
||||
beisenStaffDepartmentDto.setParentId(departmentDto.getString("parentId"));
|
||||
beisenStaffDepartmentDto.setLevel(departmentDto.getString("level"));
|
||||
beisenStaffDepartmentDto.setStatus(departmentDto.getString("status"));
|
||||
beisenStaffDepartmentDto.setIsDelete(departmentDto.getString("isDelete"));
|
||||
beisenStaffDepartmentDto.setOriginalId(departmentDto.getString("originalId"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffDepartmentDto(beisenStaffDepartmentDto);
|
||||
|
||||
BeisenStaffPositionDto beisenStaffPositionDto = new BeisenStaffPositionDto();
|
||||
if(itemObject.containsKey("positionDto")){
|
||||
JSONObject positionDto = itemObject.getJSONObject("positionDto");
|
||||
|
||||
beisenStaffPositionDto.setId(positionDto.getString("id"));
|
||||
beisenStaffPositionDto.setName(positionDto.getString("name"));
|
||||
beisenStaffPositionDto.setCode(positionDto.getString("code"));
|
||||
beisenStaffPositionDto.setStatus(positionDto.getString("status"));
|
||||
beisenStaffPositionDto.setIsDelete(positionDto.getString("isDelete"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffPositionDto(beisenStaffPositionDto);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenStaffDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryUserInfoByStaffCode(String token,String staffcode){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.userInfoUrl+"?staffCode="+staffcode)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
log.error("msg:"+response.body().string());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenDepartmentDto;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenDeptInfoByOriginalIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenDeptInfoByOriginalIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenDepartmentDto getBeisenDeptDataByOriginalId(String originalId){
|
||||
BeisenDepartmentDto beisenDepartmentDto = new BeisenDepartmentDto();
|
||||
if(StringUtils.isNotEmpty(originalId)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryDeptDataByOriginalId(token,originalId);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
log.error("code:{}",code);
|
||||
if("200".equals(code)){
|
||||
if(bodyJson.containsKey("items")){
|
||||
String items = bodyJson.getString("items");
|
||||
if(!"[]".equals(items)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
if(itemsArray.size() > 0){
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
log.error("itemsArray:{}",itemsArray.size());
|
||||
log.error("itemObject:{}",itemObject.toJSONString());
|
||||
|
||||
log.error("orgId:{}",itemObject.getString("orgId"));
|
||||
int orgId = -1;
|
||||
String orgIdStr = itemObject.getString("orgId");
|
||||
if(StringUtils.isNotBlank(orgIdStr)){
|
||||
orgId = Integer.valueOf(orgIdStr);
|
||||
}
|
||||
beisenDepartmentDto.setOrgId(orgId);
|
||||
|
||||
beisenDepartmentDto.setName(itemObject.getString("name"));
|
||||
beisenDepartmentDto.setCode(itemObject.getString("code"));
|
||||
|
||||
beisenDepartmentDto.setAbbreviation(itemObject.getString("abbreviation"));
|
||||
beisenDepartmentDto.setParentOriginalId(itemObject.getString("parentOriginalId"));
|
||||
beisenDepartmentDto.setOriginalId(itemObject.getString("originalId"));
|
||||
beisenDepartmentDto.setOrderId(itemObject.getString("orderId"));
|
||||
beisenDepartmentDto.setStatus(itemObject.getString("status"));
|
||||
beisenDepartmentDto.setIsDelete(itemObject.getString("isDelete"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenDepartmentDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryDeptDataByOriginalId(String token,String originalId){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.deppartmentUrl+"?originalId="+originalId)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
log.error("bodyData:{}",bodyData);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenQueryDeptIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenQueryDeptIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public String queryBeisenDeptIdByCode(String code){
|
||||
String deptid = "";
|
||||
if(StringUtils.isNotEmpty(code)) {
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
deptid = queryDeptIdByCode(token, code);
|
||||
}
|
||||
}
|
||||
return deptid;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param deptcode
|
||||
* @return
|
||||
*/
|
||||
private String queryDeptIdByCode(String token,String deptcode){
|
||||
String deptid = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, "{\"codes\":[\""+deptcode+"\"]}");
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.queryDeptIdByCodeUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200) {
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(msg);
|
||||
if(bodyJson.containsKey("data")){
|
||||
JSONArray dataArray = bodyJson.getJSONArray("data");
|
||||
if(dataArray.size() > 0){
|
||||
JSONObject itemJson = dataArray.getJSONObject(0);
|
||||
if(itemJson.containsKey("oId")){
|
||||
deptid = itemJson.getString("oId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
log.error("deptid:{}",deptid);
|
||||
return deptid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenQueryUseridUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenQueryUseridUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public String queryBeisenUserIdByEmail(String email){
|
||||
String userid = "";
|
||||
if(StringUtils.isNotEmpty(email)) {
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
userid = queryUserIdByEmail(token, email);
|
||||
}
|
||||
}
|
||||
return userid;
|
||||
}
|
||||
|
||||
|
||||
public String queryBeisenUserIdByJobNum(String jobNum){
|
||||
String userid = "";
|
||||
if(StringUtils.isNotEmpty(jobNum)) {
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
userid = queryUserIdByJobNum(token, jobNum);
|
||||
}
|
||||
}
|
||||
return userid;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
private String queryUserIdByEmail(String token,String email){
|
||||
String userid = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("email",email);
|
||||
RequestBody body = RequestBody.create(mediaType, dataJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.queryUserIdByEmailUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200) {
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(msg);
|
||||
if(bodyJson.containsKey("data")){
|
||||
userid = bodyJson.getString("data");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
log.error("userid:{}",userid);
|
||||
return userid;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param jobNum
|
||||
* @return
|
||||
*/
|
||||
private String queryUserIdByJobNum(String token,String jobNum){
|
||||
String userid = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, "{\n \"jobNumbers\":[\""+jobNum+"\"]\n}");
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.queryUserIdByCodeUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
String msg = response.body().string();
|
||||
if(code == 200) {
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(msg);
|
||||
if(bodyJson.containsKey("data")){
|
||||
JSONArray dataArray = bodyJson.getJSONArray("data");
|
||||
if(dataArray.size() > 0){
|
||||
JSONObject itemJson = dataArray.getJSONObject(0);
|
||||
if(itemJson.containsKey("userId")){
|
||||
userid = itemJson.getString("userId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
log.error("userid:{}",userid);
|
||||
return userid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffPositionDto;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenStaffInfoByStaffCodeUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenStaffInfoByStaffCodeUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenStaffDto getBeisenStaffInfoByStaffCode(String staffcode){
|
||||
BeisenStaffDto beisenStaffDto = new BeisenStaffDto();
|
||||
if(StringUtils.isNotEmpty(staffcode)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryUserInfoByStaffCode(token,staffcode);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
log.error("code:{}",code);
|
||||
if("200".equals(code)){
|
||||
String items = bodyJson.getString("items");
|
||||
if(!"[]".equals(items)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
log.error("itemsArray:{}",itemsArray.size());
|
||||
if(itemsArray.size() > 0){
|
||||
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
log.error("itemObject:{}",itemObject.size());
|
||||
|
||||
if(itemObject.containsKey("staffDto")){
|
||||
JSONObject staffDto = itemObject.getJSONObject("staffDto");
|
||||
log.error("staffDto:{}",staffDto.size());
|
||||
beisenStaffDto.setDepartmentId(staffDto.getString("departmentId"));
|
||||
beisenStaffDto.setDepartmentName(staffDto.getString("departmentName"));
|
||||
String employedDate = staffDto.getString("employedDate");
|
||||
log.error("employedDate:{}",employedDate);
|
||||
if(!"null".equals(employedDate) && employedDate !=null ){
|
||||
if(employedDate.contains("T")){
|
||||
employedDate = employedDate.substring(0,employedDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
log.error("employedDate:{}",employedDate);
|
||||
|
||||
beisenStaffDto.setEmployedDate(employedDate);
|
||||
|
||||
beisenStaffDto.setJobCode(staffDto.getString("jobCode"));
|
||||
beisenStaffDto.setPositionName(staffDto.getString("positionName"));
|
||||
beisenStaffDto.setLineManagerId(staffDto.getString("lineManagerId"));
|
||||
beisenStaffDto.setStaffCode(staffDto.getString("staffCode"));
|
||||
beisenStaffDto.setStaffStatus(staffDto.getString("staffStatus"));
|
||||
beisenStaffDto.setIsDelete(staffDto.getString("isDelete"));
|
||||
String useridStr = staffDto.getString("userId");
|
||||
int userid = -1 ;
|
||||
if(StringUtils.isNotBlank(useridStr)){
|
||||
try{
|
||||
userid = Integer.valueOf(useridStr);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
beisenStaffDto.setUserId(userid);
|
||||
|
||||
beisenStaffDto.setTenantId(staffDto.getString("tenantId"));
|
||||
beisenStaffDto.setEmail(staffDto.getString("email"));
|
||||
beisenStaffDto.setUserType(staffDto.getString("userType"));
|
||||
beisenStaffDto.setUserStatus(staffDto.getString("userStatus"));
|
||||
beisenStaffDto.setOrigin(staffDto.getString("origin"));
|
||||
beisenStaffDto.setOriginalId(staffDto.getString("originalId"));
|
||||
beisenStaffDto.setName(staffDto.getString("name"));
|
||||
beisenStaffDto.setEnglishName(staffDto.getString("englishName"));
|
||||
beisenStaffDto.setSex(staffDto.getString("sex"));
|
||||
String birthday = staffDto.getString("birthday");
|
||||
|
||||
if(!"null".equals(birthday) && birthday !=null ){
|
||||
if(birthday.contains("T")){
|
||||
birthday = birthday.substring(0,birthday.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setBirthday(birthday);
|
||||
beisenStaffDto.setMobile(staffDto.getString("mobile"));
|
||||
beisenStaffDto.setIdCardType(staffDto.getString("idCardType"));
|
||||
|
||||
String graduateDate = staffDto.getString("graduateDate");
|
||||
|
||||
if(!"null".equals(graduateDate) && graduateDate !=null ){
|
||||
if(graduateDate.contains("T")){
|
||||
graduateDate = graduateDate.substring(0,graduateDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.error("graduateDate:{}",graduateDate);
|
||||
beisenStaffDto.setGraduateDate(graduateDate);
|
||||
|
||||
beisenStaffDto.setNativePlace(staffDto.getString("nativePlace"));
|
||||
String beganWorkDate = staffDto.getString("beganWorkDate");
|
||||
|
||||
if(!"null".equals(beganWorkDate) && beganWorkDate !=null ){
|
||||
if(beganWorkDate.contains("T")){
|
||||
beganWorkDate = beganWorkDate.substring(0,beganWorkDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
log.error("graduateDate:{}",graduateDate);
|
||||
beisenStaffDto.setBeganWorkDate(beganWorkDate);
|
||||
beisenStaffDto.setGraduateFrom(staffDto.getString("graduateFrom"));
|
||||
beisenStaffDto.setMajor(staffDto.getString("major"));
|
||||
beisenStaffDto.setPositionCategory(staffDto.getString("positionCategory"));
|
||||
}
|
||||
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto = new BeisenStaffDepartmentDto();
|
||||
if(itemObject.containsKey("departmentDto")){
|
||||
JSONObject departmentDto = itemObject.getJSONObject("departmentDto");
|
||||
beisenStaffDepartmentDto.setId(departmentDto.getString("id"));
|
||||
beisenStaffDepartmentDto.setName(departmentDto.getString("name"));
|
||||
beisenStaffDepartmentDto.setCode(departmentDto.getString("code"));
|
||||
beisenStaffDepartmentDto.setAbbreviation(departmentDto.getString("abbreviation"));
|
||||
beisenStaffDepartmentDto.setParentId(departmentDto.getString("parentId"));
|
||||
beisenStaffDepartmentDto.setLevel(departmentDto.getString("level"));
|
||||
beisenStaffDepartmentDto.setStatus(departmentDto.getString("status"));
|
||||
beisenStaffDepartmentDto.setIsDelete(departmentDto.getString("isDelete"));
|
||||
beisenStaffDepartmentDto.setOriginalId(departmentDto.getString("originalId"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffDepartmentDto(beisenStaffDepartmentDto);
|
||||
|
||||
BeisenStaffPositionDto beisenStaffPositionDto = new BeisenStaffPositionDto();
|
||||
if(itemObject.containsKey("positionDto")){
|
||||
JSONObject positionDto = itemObject.getJSONObject("positionDto");
|
||||
|
||||
beisenStaffPositionDto.setId(positionDto.getString("id"));
|
||||
beisenStaffPositionDto.setName(positionDto.getString("name"));
|
||||
beisenStaffPositionDto.setCode(positionDto.getString("code"));
|
||||
beisenStaffPositionDto.setStatus(positionDto.getString("status"));
|
||||
beisenStaffPositionDto.setIsDelete(positionDto.getString("isDelete"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffPositionDto(beisenStaffPositionDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenStaffDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryUserInfoByStaffCode(String token,String staffcode){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.userInfoUrl+"?staffCode="+staffcode)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:"+e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
public class BlackList2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BlackList2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public String createBlackList4NonSystem(String token,String name,String staffEmail,String blackAddReason,String blackStaffDesc){
|
||||
|
||||
log.error("createBlackList4NonSystem");
|
||||
String objectId = "";
|
||||
|
||||
// 选项名称 选项编码 启用状态
|
||||
//重大违纪 1 启用
|
||||
//诚信问题 2 启用
|
||||
//稳定性差 3 启用
|
||||
//辞职 4 启用
|
||||
//其他 5 启用
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("name",name);
|
||||
dataJson.put("staffEmail",staffEmail);
|
||||
dataJson.put("blackAddReason",blackAddReason);
|
||||
dataJson.put("blackStaffDesc",blackStaffDesc);
|
||||
|
||||
// dataJson.put("name","王芳");
|
||||
// dataJson.put("staffEmail","798989044@qq.com");
|
||||
// dataJson.put("blackAddReason","3");
|
||||
// dataJson.put("blackStaffDesc","做事不认真");
|
||||
|
||||
bodyJson.put("data",dataJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/Create
|
||||
// "{\n \"data\": {\n \"name\": \"测试王芳\",\n \"staffEmail\": \"798989044@qq.com\",\n \"blackAddReason\":\"3\",\n \"blackStaffDesc\":\"做事不认真\"\n }\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+ Constants.createBlackListUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
log.error("code:{}",code);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("objectId")){
|
||||
objectId = dataObject.getString("objectId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
|
||||
log.error("objectId:{}",objectId);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return objectId;
|
||||
}
|
||||
|
||||
|
||||
public String createBlackList4ResignUser(String token,String userID,String lastWorkDate,String blackAddReason,String blackStaffDesc){
|
||||
log.error("createBlackList4ResignUser");
|
||||
String objectId = "";
|
||||
|
||||
// 选项名称 选项编码 启用状态
|
||||
//重大违纪 1 启用
|
||||
//诚信问题 2 启用
|
||||
//稳定性差 3 启用
|
||||
//辞职 4 启用
|
||||
//其他 5 启用
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("userID",userID);
|
||||
dataJson.put("blackListSource","1");
|
||||
dataJson.put("lastWorkDate",lastWorkDate);
|
||||
dataJson.put("blackAddReason",blackAddReason);
|
||||
dataJson.put("blackStaffDesc",blackStaffDesc);
|
||||
|
||||
// dataJson.put("userID","王芳");
|
||||
// dataJson.put("blackListSource","1");
|
||||
// dataJson.put("lastWorkDate","2025-05-30");
|
||||
// dataJson.put("blackAddReason","3");
|
||||
// dataJson.put("blackStaffDesc","做事不认真");
|
||||
|
||||
bodyJson.put("data",dataJson);
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/Create
|
||||
// "{\n \"data\": {\n \"name\": \"测试王芳\",\n \"staffEmail\": \"798989044@qq.com\",\n \"blackAddReason\":\"3\",\n \"blackStaffDesc\":\"做事不认真\"\n }\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.createBlackListUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
System.out.println("code:"+code);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("objectId")){
|
||||
objectId = dataObject.getString("objectId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/***
|
||||
* 批量删除黑名单
|
||||
* @param token
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
public String batchDeleteBlackList(String token,List<String> idList){
|
||||
|
||||
String msg = "";
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("Ids",idList);
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/BatchDelete
|
||||
// "{\n \"Ids\": [\n \"0441166f-468e-425f-9163-4a9d922169e3\"\n ]\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.deleteBlackListUrl)
|
||||
.method("DELETE", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
if(code == 200 ){
|
||||
msg = response.body().string();
|
||||
}
|
||||
log.error("msg:"+msg);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,422 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class EbuilderOperateUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EbuilderOperateUtils.class);
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
@RpcReference(group = "ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
|
||||
public EBDataChangeResult bacthInsertDbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
log.error("bacthInsertDbForm");
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
// 主表数据参数
|
||||
// Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
// if("uf_yzgl".equals(formTable)){
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(fieldList.get(n).equals("yzzl")){
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, "2"));
|
||||
// }else{
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }else{
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthEditEbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
if (StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)) {
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
/**
|
||||
* 直接通过id更新数据, 即update table set a = '11' where id = 1
|
||||
*/
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 若数据写入后就要从前台看到数据或者立即操作本次写入的数据, 需要调整后置处理为同步 权限处理完成再返回
|
||||
ebDataReqOperation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
// 数据没有找到的时候是否新增数据
|
||||
EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo();
|
||||
ebDataReqOperationInfo.setNeedAdd(true);
|
||||
ebDataReqOperation.setMainData(ebDataReqOperationInfo);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class EbuilderUtils {
|
||||
|
||||
@RpcReference(group="ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
public EBDataChangeResult bacthInsertDbForm(String referrer_id,int points,String talent_id) {
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader("1120080325150089217", Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// 主表数据参数
|
||||
List<EBDataReqDetailDto> mainData1 = new ArrayList<EBDataReqDetailDto>();
|
||||
// 单行文本
|
||||
mainData1.add(new EBDataReqDetailDto("1120080376580644871", referrer_id));
|
||||
mainData1.add(new EBDataReqDetailDto("1120080376580644872", String.valueOf(points)));
|
||||
ebDataReqDto.setMainDatas(mainData1);
|
||||
|
||||
// 明细数据参数
|
||||
Map<Long, List<List<EBDataReqDetailDto>>> detailDatas = new HashMap<>();
|
||||
// 多条明细数据
|
||||
List<List<EBDataReqDetailDto>> subFormDatas = new ArrayList<>();
|
||||
// 单明细数据不同字段值 - 明细数据1
|
||||
List<EBDataReqDetailDto> subFormRowData1 = new ArrayList<>();
|
||||
subFormRowData1.add(new EBDataReqDetailDto("1120167723322155008", talent_id,false));
|
||||
subFormRowData1.add(new EBDataReqDetailDto("1120080728843460609", String.valueOf(points),false));
|
||||
subFormDatas.add(subFormRowData1);
|
||||
detailDatas.put(1120080376580644874L, subFormDatas);
|
||||
ebDataReqDto.setDetailDatas(detailDatas);
|
||||
|
||||
datas.add(ebDataReqDto);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
EBDataChangeResult ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
|
||||
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthAppendEbDetail(String rcid,int points,String mainid) {
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader("1120080325150089217", Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 数据组装
|
||||
List<EBDataReqDto> datas = new ArrayList<>();
|
||||
// 第一个数据项
|
||||
EBDataReqDto ebDataReqDto1 = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainDatas1 = new ArrayList<>();
|
||||
// 主表数据组装
|
||||
mainDatas1.add(new EBDataReqDetailDto("id", mainid, false));
|
||||
ebDataReqDto1.setMainDatas(mainDatas1);
|
||||
|
||||
/****************** 设置明细操作方式 - 不做覆盖 需要追加 ******************/
|
||||
Map<Long, EBDataReqOperationInfo> detailDatas = new HashMap<>();
|
||||
EBDataReqOperationInfo detailOperation = new EBDataReqOperationInfo();
|
||||
detailOperation.setCover(false);
|
||||
detailOperation.setNeedAdd(true);
|
||||
detailDatas.put(1120080376580644874L, detailOperation);
|
||||
ebDataReqOperation.setDetailDatas(detailDatas);
|
||||
|
||||
// 明细行数据组装
|
||||
Map<Long, List<List<EBDataReqDetailDto>>> detailDatas1 = new HashMap<>();
|
||||
List<List<EBDataReqDetailDto>> detailDataList1 = new ArrayList<>();
|
||||
List<EBDataReqDetailDto> detailData1 = new ArrayList<EBDataReqDetailDto>();
|
||||
// 第一个明细表 第一条数据
|
||||
detailData1.add(new EBDataReqDetailDto("1120167723322155008", rcid, false));
|
||||
detailData1.add(new EBDataReqDetailDto("1120080728843460609", String.valueOf(points), false));
|
||||
detailDataList1.add(detailData1);
|
||||
detailDatas1.put(1120080376580644874L, detailDataList1);
|
||||
ebDataReqDto1.setDetailDatas(detailDatas1);
|
||||
datas.add(ebDataReqDto1);
|
||||
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
|
||||
// 设置数据
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
EBDataChangeResult ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmAssessment360Dao;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2BeiSenAssessment360Util {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeiSenAssessment360Util.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
HrmAssessment360Dao hrmAssessment360Dao;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JSONArray queryAssessment360Data(){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
|
||||
List<Map<String, Object>> emailList = hrmAssessment360Dao.queryEmployeeEmail();
|
||||
for(int i=0;i<emailList.size();i++){
|
||||
Map<String, Object> emailMap = emailList.get(i);
|
||||
String email = emailMap.get("email").toString();
|
||||
if(StringUtils.isNotBlank(email)){
|
||||
JSONArray dataArray = convertAssessmentData(email);
|
||||
assessmentArray.addAll(dataArray);
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
|
||||
public JSONArray convertAssessmentData(String email){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(email)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("email",email);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
String msg = doHttpPost(token,bodyJson.toJSONString());
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject msgJson = JSONObject.parseObject(msg);
|
||||
if(msgJson.containsKey("data")){
|
||||
JSONObject dataJson = msgJson.getJSONObject("data");
|
||||
|
||||
String personnelStaffCode = "";
|
||||
String personnelMail = "";
|
||||
String personnelName = "";
|
||||
if(dataJson.containsKey("personInfo")){
|
||||
JSONObject personInfoJson = dataJson.getJSONObject("personInfo");
|
||||
if(personInfoJson.containsKey("personnelName")){
|
||||
personnelName = personInfoJson.getString("personnelName");
|
||||
}
|
||||
if(personInfoJson.containsKey("personnelMail")){
|
||||
personnelMail = personInfoJson.getString("personnelMail");
|
||||
}
|
||||
if(personInfoJson.containsKey("personnelStaffCode")){
|
||||
personnelStaffCode = personInfoJson.getString("personnelStaffCode");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("personnelStaffCode:{}",personnelStaffCode);
|
||||
log.error("personnelMail:{}",personnelMail);
|
||||
|
||||
if(dataJson.containsKey("activityList")){
|
||||
JSONArray activityListArray = dataJson.getJSONArray("activityList");
|
||||
for (int i = 0; i < activityListArray.size(); i++) {
|
||||
JSONObject activityJson = activityListArray.getJSONObject(i);
|
||||
String activityID = "";
|
||||
if(activityJson.containsKey("activityID")){
|
||||
activityID = activityJson.getString("activityID");
|
||||
}
|
||||
String activityName = "";
|
||||
if(activityJson.containsKey("activityName")){
|
||||
activityName = activityJson.getString("activityName");
|
||||
}
|
||||
String createTime = "";
|
||||
if(activityJson.containsKey("createTime")){
|
||||
createTime = activityJson.getString("createTime");
|
||||
}
|
||||
JSONArray questionnaireInfoList = new JSONArray();
|
||||
if(activityJson.containsKey("questionnaireInfoList")){
|
||||
questionnaireInfoList = activityJson.getJSONArray("questionnaireInfoList");
|
||||
}
|
||||
|
||||
log.error("activityID:{}",personnelMail);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("questionnaireInfoList:{}",questionnaireInfoList.size());
|
||||
|
||||
for(int n=0;n<questionnaireInfoList.size();n++){
|
||||
JSONObject questionnaireInfoJson = questionnaireInfoList.getJSONObject(n);
|
||||
String questionnaireID = questionnaireInfoJson.getString("questionnaireID");
|
||||
String questionnaireName = questionnaireInfoJson.getString("questionnaireName");
|
||||
String otherAvg = questionnaireInfoJson.getString("otherAvg");
|
||||
String lastUpdateTime = questionnaireInfoJson.getString("lastUpdateTime");
|
||||
log.error("questionnaireID:{}",questionnaireID);
|
||||
log.error("otherAvg:{}",otherAvg);
|
||||
log.error("lastUpdateTime:{}",lastUpdateTime);
|
||||
|
||||
JSONObject assessJson = new JSONObject();
|
||||
assessJson.put("gsyx",personnelMail);
|
||||
assessJson.put("gh",personnelStaffCode);
|
||||
assessJson.put("hdid",activityID);
|
||||
assessJson.put("hdmc",activityName);
|
||||
assessJson.put("wjid",questionnaireID);
|
||||
assessJson.put("wjmc",questionnaireName);
|
||||
assessJson.put("zzjg",otherAvg);
|
||||
assessJson.put("cjsj",createTime.replace("T"," "));
|
||||
assessJson.put("wcsj",lastUpdateTime.replace("T"," "));
|
||||
assessmentArray.add(assessJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
*/
|
||||
public String doHttpPost(String token,String bodyJson){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson);
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost + Constants.query360AssessmentUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
bodyData = msg;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2BeiSenAssessmentUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeiSenAssessmentUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param modifiedAfter
|
||||
* @param modifiedBefore
|
||||
*/
|
||||
public String getAssessmentsByFilters(String token, int page, int capacity, String modifiedAfter, String modifiedBefore) {
|
||||
String bodyData = "";
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page", page);
|
||||
bodyJson.put("capacity", capacity);
|
||||
bodyJson.put("modifiedAfter", modifiedAfter);
|
||||
bodyJson.put("modifiedBefore", modifiedBefore);
|
||||
log.error("getAssessmentsByFilters:bodyJson:{}", bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentFilterUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}", code);
|
||||
if (code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
|
||||
log.error("bodyData:{}", bodyData);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public JSONArray queryAssessmentsByPage(String token, int page, int capacity, String modifiedAfter, String modifiedBefore){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page", page);
|
||||
bodyJson.put("capacity", capacity);
|
||||
bodyJson.put("modifiedAfter", modifiedAfter);
|
||||
bodyJson.put("modifiedBefore", modifiedBefore);
|
||||
log.error("queryAssessmentsByPage:bodyJson:{}", bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentFilterUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.error("assessmentArray:{}",assessmentArray.size());
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2BeiSenPositionUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeiSenPositionUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
/***
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public String queryPositionByDate(String startDate, String endDate,int capacity){
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
String bodyData = "";
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate);
|
||||
bodyJson.put("stopTime",endDate);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
bodyJson.put("capacity",capacity);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+ Constants.positionUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = msg;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
*/
|
||||
public String queryPositionByscrollId(String startDate, String endDate,String scrollId,int capacity){
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
String bodyData = "";
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate);
|
||||
bodyJson.put("stopTime",endDate);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
bodyJson.put("scrollId",scrollId);
|
||||
bodyJson.put("capacity",capacity);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost + Constants.positionUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = msg;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/***
|
||||
* 获取考核数据
|
||||
*/
|
||||
@Component
|
||||
public class Esb2BeisenAssessUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenAssessUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param emails
|
||||
* @param beisen_account
|
||||
* @param format
|
||||
* @param consumer_key
|
||||
* @param oauth_token
|
||||
* @param oauth_signature_method
|
||||
* @param oauth_timestamp
|
||||
* @param oauth_nonce
|
||||
* @param oauth_version
|
||||
* @param oauth_signature
|
||||
*/
|
||||
public String doHttpGet(String emails,String beisen_account,String format,String consumer_key,String oauth_token,String oauth_signature_method,String oauth_timestamp,String oauth_nonce,String oauth_version,String oauth_signature){
|
||||
String msg = "";
|
||||
String applyUrl = Constants.beishenAssessHost+Constants.queryAssessUrl+"?beisen_account="+beisen_account+"&emails="+emails+"&format="+format+"&oauth_consumer_key="+consumer_key+"&oauth_token="+oauth_token+"&oauth_signature_method="+oauth_signature_method+"&oauth_timestamp="+oauth_timestamp+"&oauth_nonce="+oauth_nonce+"&oauth_version="+oauth_version+"&oauth_signature="+oauth_signature;
|
||||
log.error("applyUrl:{}",applyUrl);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(applyUrl)
|
||||
.method("GET", null)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/***
|
||||
* 查询考核数据
|
||||
* @param emails
|
||||
*/
|
||||
public void queryAssessData(String emails){
|
||||
String applyUrl = Constants.beishenAssessHost+Constants.queryAssessUrl;
|
||||
String beisen_account = Constants.beisenAccount;
|
||||
String oauth_consumer_key = Constants.consumerKey;
|
||||
String oauth_token = Constants.accessToken;
|
||||
String oauth_version = Constants.oauthVersion;
|
||||
String oauth_nonce = randomString(11);
|
||||
String oauth_signature_method = Constants.oauthSignatureMethod;
|
||||
String format = Constants.format;
|
||||
String oauth_consumer_secret = Constants.consumerSecret;
|
||||
String oauth_token_secret = Constants.tokenSecret;
|
||||
|
||||
String oauth_signature = "";
|
||||
|
||||
long oauth_timestamp = System.currentTimeMillis()/1000;
|
||||
log.error("oauth_consumer_key:{}",oauth_consumer_key);
|
||||
log.error("oauth_nonce:{}",oauth_nonce);
|
||||
log.error("oauth_timestamp:{}",oauth_timestamp);
|
||||
log.error("oauth_token:{}",oauth_token);
|
||||
log.error("oauth_version:{}",oauth_version);
|
||||
|
||||
String key = oauth_consumer_secret+"&"+oauth_token_secret ;
|
||||
log.error("key:{}",key);
|
||||
try {
|
||||
String paramData = "beisen_account="+URLEncoder.encode(beisen_account, "UTF-8")+"&emails="+URLEncoder.encode(emails, "UTF-8")+"&format="+URLEncoder.encode(format, "UTF-8")+"&oauth_consumer_key="+URLEncoder.encode(oauth_consumer_key, "UTF-8")+"&oauth_nonce="+URLEncoder.encode(oauth_nonce, "UTF-8")+"&oauth_signature_method="+URLEncoder.encode(oauth_signature_method, "UTF-8")+"&oauth_timestamp="+URLEncoder.encode(oauth_timestamp+"", "UTF-8")+"&oauth_token="+URLEncoder.encode(oauth_token, "UTF-8")+"&oauth_version="+URLEncoder.encode(oauth_version, "UTF-8");
|
||||
log.error("paramData:{}",paramData);
|
||||
String encodeParamData = URLEncoder.encode(paramData, "UTF-8");
|
||||
log.error("encodeParamData:{}",encodeParamData);
|
||||
String concatData = "POST&"+URLEncoder.encode(applyUrl, "UTF-8")+"&"+encodeParamData;
|
||||
oauth_signature = calculateHmacSha1(key, concatData);
|
||||
log.error("oauth_signature:{}",oauth_signature);
|
||||
oauth_signature = URLEncoder.encode(oauth_signature, "UTF-8");
|
||||
log.error("oauth_signature2:{}",oauth_signature);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(oauth_signature)){
|
||||
String msg = doHttpGet(emails,beisen_account,format,oauth_consumer_key,oauth_token,oauth_signature_method,oauth_timestamp+"",oauth_nonce,oauth_version,oauth_signature);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 计算HmacSHA1
|
||||
* @param key
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public String calculateHmacSha1(String key, String message) {
|
||||
String data = "";
|
||||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "HmacSHA1");
|
||||
mac.init(secretKeySpec);
|
||||
byte[] digest = mac.doFinal(message.getBytes());
|
||||
data = Base64.getEncoder().encodeToString(digest);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
log.error("e:{}",e.getMessage());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String randomString(int length){
|
||||
String data = UUID.randomUUID().toString();
|
||||
// 定义可能的字符
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = ThreadLocalRandom.current().nextInt(characters.length());
|
||||
sb.append(characters.charAt(index));
|
||||
}
|
||||
data = sb.toString();
|
||||
return data;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class Esb2BeisenUnRelateRequestUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenUnRelateRequestUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
public String unRelateJobRequirement(String requirementId){
|
||||
|
||||
String dataCode = "";
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
int operationType = 1;
|
||||
bodyJson.put("operationType",operationType);
|
||||
bodyJson.put("id",requirementId);
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.unRelateRequirementUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String bodyData = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject dataJson = JSONObject.parseObject(bodyData);
|
||||
if(dataJson.containsKey("code")){
|
||||
dataCode = dataJson.getString("code");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("bodyData:"+bodyData);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return dataCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class JobRequirement2BeisenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(JobRequirement2BeisenUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public String sendJobRequirement(int requirementStatus,
|
||||
int requirementType,
|
||||
String requestname,
|
||||
int beisenCreateBy,
|
||||
String createDate,
|
||||
int requirementCount,
|
||||
String arivalTime,
|
||||
String createByEmail,
|
||||
String dutyUserEmail,
|
||||
int beisenDepartmentId,
|
||||
int salaryType,
|
||||
int category,
|
||||
String educationInfo,
|
||||
String workExperience,
|
||||
int kind,
|
||||
boolean isSecrecy,
|
||||
String originalCode,
|
||||
String nlyq,
|
||||
String zpgw,
|
||||
String zwmc,
|
||||
int beisenDutyUserId,
|
||||
String xqmc,
|
||||
String gzzz,
|
||||
String rzzg,
|
||||
String zxssyf,
|
||||
String jjcd
|
||||
){
|
||||
String data = "";
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
/***
|
||||
* 需求状态
|
||||
* 10 草稿
|
||||
* 20 审批中
|
||||
* 30 审批未通过
|
||||
* 40 进行中
|
||||
* 50 已关闭
|
||||
* 60 已完成
|
||||
* 70 已暂停
|
||||
* 80 审批已终止
|
||||
*
|
||||
*/
|
||||
if(requirementStatus > -1){
|
||||
bodyJson.put("requirementStatus",requirementStatus);
|
||||
}
|
||||
|
||||
/***
|
||||
* 需求类型
|
||||
* 1 新增
|
||||
* 2 顶替
|
||||
* 3 储备
|
||||
*/
|
||||
if(requirementType > -1){
|
||||
bodyJson.put("requirementType",requirementType);
|
||||
}
|
||||
|
||||
|
||||
bodyJson.put("name",xqmc);
|
||||
log.error("beisenCreateBy:{}",beisenCreateBy);
|
||||
if(beisenCreateBy > -1){
|
||||
bodyJson.put("createBy",beisenCreateBy);
|
||||
}
|
||||
|
||||
if(!createDate.contains("T")){
|
||||
createDate = createDate+"T00:00:00";
|
||||
}
|
||||
bodyJson.put("createDate",createDate);
|
||||
|
||||
if(!arivalTime.contains("T")){
|
||||
arivalTime = arivalTime+"T00:00:00";
|
||||
}
|
||||
bodyJson.put("arivalTime",arivalTime);
|
||||
|
||||
bodyJson.put("dutyUserEmail",dutyUserEmail);
|
||||
bodyJson.put("createByEmail",createByEmail);
|
||||
|
||||
if(beisenDepartmentId > -1){
|
||||
bodyJson.put("departmentId",beisenDepartmentId);
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(originalCode)){
|
||||
bodyJson.put("orgCode",originalCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 需求人数
|
||||
*/
|
||||
if(requirementCount > -1){
|
||||
bodyJson.put("requirementCount",requirementCount);
|
||||
}
|
||||
|
||||
// if(salaryType >-1){
|
||||
// bodyJson.put("salaryType",salaryType);
|
||||
// }
|
||||
|
||||
// bodyJson.put("PositionIdCoreHR","d948d6ce-70cc-4265-975c-fea732759676");
|
||||
|
||||
/***
|
||||
* 招聘类别
|
||||
* 1 社会招聘
|
||||
* 2 校园招聘
|
||||
* 3 实习生招聘
|
||||
*/
|
||||
|
||||
if(category > -1){
|
||||
bodyJson.put("category",category);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 学历要求
|
||||
* 9 小学
|
||||
* 8 初中
|
||||
* 3 高中
|
||||
* 4 中技(中专/技校/职高)
|
||||
* 5 大专
|
||||
* 1 本科
|
||||
* 2 硕士研究生
|
||||
* 6 MBA
|
||||
* 7 博士研究生
|
||||
* 10 大专及以上
|
||||
* 11 本科及以上
|
||||
* 12 不限
|
||||
*/
|
||||
bodyJson.put("educationInfo",educationInfo);
|
||||
/***
|
||||
* 工作经验
|
||||
* 在读学生
|
||||
* 应届毕业生
|
||||
* 99 在读学生
|
||||
* 98 应届毕业生
|
||||
* 1 1年
|
||||
* 2 2年
|
||||
* 3 3年
|
||||
* 4 4年
|
||||
* 5 5年
|
||||
* 6 6年
|
||||
* 7 7年
|
||||
* 8 8年
|
||||
* 9 9年
|
||||
* 10 10年及以上
|
||||
*/
|
||||
bodyJson.put("workExperience",workExperience);
|
||||
|
||||
/***
|
||||
* 工作性质
|
||||
* 1 全职
|
||||
* 2 兼职
|
||||
* 3 实习
|
||||
* 4 其他
|
||||
*/
|
||||
|
||||
if(kind > -1){
|
||||
bodyJson.put("kind",kind);
|
||||
}
|
||||
if(StringUtils.isNotBlank(nlyq)){
|
||||
JSONObject customProperties = new JSONObject();
|
||||
customProperties.put(Constants.nyyqzdm,nlyq);
|
||||
customProperties.put(Constants.zwzd,zwmc);
|
||||
|
||||
customProperties.put(Constants.zpssyfzd,zxssyf);
|
||||
customProperties.put(Constants.jjcdzdm,jjcd);
|
||||
|
||||
bodyJson.put("customProperties",customProperties);
|
||||
}
|
||||
log.error("beisenDutyUserId:{}",beisenDutyUserId);
|
||||
if(beisenDutyUserId>-1){
|
||||
bodyJson.put("dutyUser",beisenDutyUserId);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(gzzz)){
|
||||
bodyJson.put("jobDescription",gzzz);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(rzzg)){
|
||||
bodyJson.put("qualification",rzzg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bodyJson.put("isSecrecy",isSecrecy);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
data = doHttpPost(token,bodyJson.toJSONString());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public String doHttpPost(String token,String bodyJson){
|
||||
String data = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.jobRequirementUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String bodyData = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject dataJson = JSONObject.parseObject(bodyData);
|
||||
if(dataJson.containsKey("code")){
|
||||
String dataCode = dataJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
data = dataJson.getString("data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Offer2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Offer2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public JSONArray queryOfferByDateTime(String token,String startDate, String startTime, String endDate, String endTime){
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
JSONArray offerArray = new JSONArray();
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+ Constants.offerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
offerArray.addAll(dataArray);
|
||||
String scrollId = returnJson.getString("scrollId");
|
||||
if(StringUtils.isNotBlank(scrollId)){
|
||||
queryOfferByscrollId(token, startDate, startTime, endDate, endTime,offerArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return offerArray;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @param offerArray
|
||||
*/
|
||||
public void queryOfferByscrollId(String token, String startDate, String startTime, String endDate, String endTime,JSONArray offerArray){
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.offerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
offerArray.addAll(dataArray);
|
||||
String scrollId = returnJson.getString("scrollId");
|
||||
if(StringUtils.isNotBlank(scrollId)){
|
||||
queryOfferByscrollId(token, startDate, startTime, endDate, endTime,dataArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Performance2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Performance2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param year
|
||||
* @param period
|
||||
*/
|
||||
public String getActivityManagerCount(String token,String page,String capacity,String year,String period){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("year",year);
|
||||
bodyJson.put("period",period);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"year\": 2024,\n \"period\": 8\n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/ActivityManager/GetActivityManagers"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.activityManagerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData ;
|
||||
}
|
||||
|
||||
|
||||
public JSONArray queryActivityManager(String token,String page,String capacity,String year,String period){
|
||||
JSONArray performanceArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("year",year);
|
||||
bodyJson.put("period",period);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"year\": 2024,\n \"period\": 8\n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/ActivityManager/GetActivityManagers"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.activityManagerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
performanceArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return performanceArray;
|
||||
}
|
||||
|
||||
|
||||
public String getAssessmentItemCount(String token,String page,String capacity,String activityManagerId){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("activityManagerId",activityManagerId);
|
||||
JSONObject sortJson = new JSONObject();
|
||||
sortJson.put("Name",-1);
|
||||
bodyJson.put("sort",sortJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"sort\": {\n \"Name\": -1\n },\n \"activityManagerId\": \"62822578-2bba-4980-9826-00689705c58d\"\n \n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItems"
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public JSONArray queryAssessmentItem(String token,String page,String capacity,String activityManagerId){
|
||||
JSONArray assessmentItemArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("activityManagerId",activityManagerId);
|
||||
JSONObject sortJson = new JSONObject();
|
||||
sortJson.put("Name",-1);
|
||||
bodyJson.put("sort",sortJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentItemArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return assessmentItemArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public String getAssessmentCount(String token,String activityManagerId){
|
||||
// String bodyData = "";
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// String[] columns = new String[]{"_id","Name","ModifiedTime","ActivityManagerId"};
|
||||
// bodyJson.put("columns",columns);
|
||||
// String[] assessmentIds = new String[]{activityManagerId};
|
||||
// bodyJson.put("assessmentIds",assessmentIds);
|
||||
//
|
||||
// // "{\n \"columns\":[\n \"_id\",\n \"Name\",\n \"ModifiedTime\",\n \"ActivityManagerId\"\n ],\n \"assessmentIds\" : [\"2e0c22bc-7295-4993-961b-822053f70563\"]\n}"
|
||||
// // "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds"
|
||||
//
|
||||
// RequestBody body = RequestBody.create(mediaType,bodyJson.toJSONString());
|
||||
// Request request = new Request.Builder()
|
||||
// .url(Constants.beishenHost+Constants.assessmentUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .build();
|
||||
// try {
|
||||
// Response response = client.newCall(request).execute();
|
||||
// int code = response.code();
|
||||
// log.error("code:{}",code);
|
||||
// if(code == 200){
|
||||
// bodyData = response.body().string();
|
||||
// }else{
|
||||
// String msg = response.body().string();
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return bodyData;
|
||||
// }
|
||||
|
||||
public JSONArray queryAssessment(String token,String activityManagerId){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
String[] columns = new String[]{"_id","Name","ModifiedTime","ActivityManagerId"};
|
||||
bodyJson.put("columns",columns);
|
||||
String[] assessmentIds = new String[]{activityManagerId};
|
||||
bodyJson.put("assessmentIds",assessmentIds);
|
||||
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.seconddev.chapanda.beisen.cache.BeisenTokenCacheKey;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.module.BeisenTokenModuleKey;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
|
||||
@Component
|
||||
public class Token2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Token2BeiSenUtil.class);
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
public int earlySecond = 120;
|
||||
|
||||
/***
|
||||
* 获取token
|
||||
*/
|
||||
public String getToken(){
|
||||
|
||||
String token = (String) baseCache.get(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, BeisenTokenCacheKey.BEISEN_TOKEN);
|
||||
log.error("token:{}",token);
|
||||
try{
|
||||
if (StringUtils.isBlank(token)) {
|
||||
JSONObject returnJson = getAccessToken();
|
||||
log.error("returnJson:{}",returnJson.toJSONString());
|
||||
|
||||
if(returnJson.containsKey("access_token")){
|
||||
token = returnJson.getString("access_token");
|
||||
String expire = returnJson.getString("expires_in");
|
||||
log.error("token22:{}",token);
|
||||
log.error("expire22:{}",expire);
|
||||
if(StringUtils.isNotBlank(expire)){
|
||||
int expire2 = earlySecond;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(expire)){
|
||||
expire2 = Integer.valueOf(expire);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e3:{}",e);
|
||||
}
|
||||
log.error("expire23:{}",expire2);
|
||||
if(expire2 > 0){
|
||||
log.error("expire3:{}",expire2);
|
||||
baseCache.set(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, BeisenTokenCacheKey.BEISEN_TOKEN, token, expire2-earlySecond);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e2:{}",e);
|
||||
}
|
||||
|
||||
log.error("token4:{}",token);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/***
|
||||
* http方式请求获取token
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getAccessToken(){
|
||||
JSONObject accessTokenJson = new JSONObject();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("app_key", Constants.app_key);
|
||||
bodyJson.put("app_secret",Constants.app_secret);
|
||||
bodyJson.put("grant_type","client_credentials");
|
||||
|
||||
log.error("bodyJson:{}",bodyJson);
|
||||
//"https://openapi.italent.cn/token"
|
||||
// "{\n \"grant_type\":\"client_credentials\",\n \"app_key\":\"0F0F2B3F6356464EB59FB651E8DAACBA\",\n \"app_secret\":\"AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003\"\n}"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.tokenUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
accessTokenJson = JSONObject.parseObject(msg);
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("IOException:{}",e);
|
||||
}
|
||||
return accessTokenJson;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param beishenHost
|
||||
* @param offerUrl
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
// public JSONArray queryOfferByDateTime(String token, String beishenHost, String offerUrl, String startDate, String startTime, String endDate, String endTime){
|
||||
//
|
||||
// // https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
//// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
// JSONArray offerArray = new JSONArray();
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
// bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
// bodyJson.put("timeWindowQueryType","1");
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(beishenHost+offerUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
//
|
||||
// int code = response.code();
|
||||
// String msg = response.body().string();
|
||||
// System.out.println("code:"+code);
|
||||
// if(code == 200){
|
||||
// if(StringUtils.isNotBlank(msg)){
|
||||
// JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
// if(returnJson.containsKey("code")){
|
||||
// String dataCode = returnJson.getString("code");
|
||||
// if("200".equals(dataCode)){
|
||||
// JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
// offerArray.addAll(dataArray);
|
||||
// String scrollId = returnJson.getString("scrollId");
|
||||
// if(StringUtils.isNotBlank(scrollId)){
|
||||
// queryOfferByscrollId(token,beishenHost, offerUrl, startDate, startTime, endDate, endTime,offerArray);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return offerArray;
|
||||
// }
|
||||
|
||||
// /***
|
||||
// *
|
||||
// * @param token
|
||||
// * @param beishenHost
|
||||
// * @param offerUrl
|
||||
// * @param startDate
|
||||
// * @param startTime
|
||||
// * @param endDate
|
||||
// * @param endTime
|
||||
// * @param offerArray
|
||||
// */
|
||||
// public void queryOfferByscrollId(String token, String beishenHost, String offerUrl, String startDate, String startTime, String endDate, String endTime,JSONArray offerArray){
|
||||
//
|
||||
// // https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
//// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
//
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
// bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
// bodyJson.put("timeWindowQueryType","1");
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(beishenHost+offerUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
//
|
||||
// int code = response.code();
|
||||
// String msg = response.body().string();
|
||||
// log.error("code:{}",code);
|
||||
// if(code == 200){
|
||||
// if(StringUtils.isNotBlank(msg)){
|
||||
// JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
// if(returnJson.containsKey("code")){
|
||||
// String dataCode = returnJson.getString("code");
|
||||
// if("200".equals(dataCode)){
|
||||
// JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
// offerArray.addAll(dataArray);
|
||||
// String scrollId = returnJson.getString("scrollId");
|
||||
// if(StringUtils.isNotBlank(scrollId)){
|
||||
// queryOfferByscrollId(token,beishenHost, offerUrl, startDate, startTime, endDate, endTime,dataArray);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.weaver.seconddev.chapanda.cost.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
|
||||
public static String HrmHost = "https://hrtest.chabaidao.com";
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.util.CommonUtils;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sapi/secondev/cbd/hrm")
|
||||
public class ConvertStaffCodeController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ConvertStaffCodeController.class);
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/convStaffCode")
|
||||
public WeaResult<Object> convStaffCode(@RequestBody Map<String, Object> params){
|
||||
Map<String,Object> recordMap = convertStaffCodeService.convStaffCode(params);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sapi/secondev/cbd/workflow")
|
||||
public class Request2CostControlController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(Request2CostControlController.class);
|
||||
|
||||
@Autowired
|
||||
Request2CostControlService request2CostControlService;
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/queryRequestByWorkflowType")
|
||||
public WeaResult<Object> queryRequestByWorkflowType(@RequestBody Map<String, Object> params) {
|
||||
log.error("queryRequestByWorkflowType");
|
||||
|
||||
// int pageNo2 = 1;
|
||||
// int pgeSize2 = 100;
|
||||
// boolean noIsNumber = false;
|
||||
// if(params.containsKey("pageNo")){
|
||||
// String page_no = String.valueOf(params.get("pageNo"));
|
||||
// if(StringUtils.isNotBlank(page_no)){
|
||||
// try {
|
||||
// pageNo2 = Integer.getInteger(page_no);
|
||||
// log.error("pageNo:{}",pageNo2);
|
||||
// noIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// noIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean sizeIsNumber = false;
|
||||
// if(params.containsKey("pageSize")){
|
||||
// String page_size = String.valueOf(params.get("pageSize"));
|
||||
// if(StringUtils.isNotBlank(page_size)){
|
||||
// try {
|
||||
// pgeSize2 = Integer.getInteger(page_size);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
// sizeIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// sizeIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
int page_no = 1;
|
||||
boolean pageIsNumber = false;
|
||||
if(params.containsKey("page")){
|
||||
String page = String.valueOf(params.get("page"));
|
||||
log.error("page:{}",page);
|
||||
if(StringUtils.isNotBlank(page)){
|
||||
try {
|
||||
page_no = Integer.valueOf(page);
|
||||
log.error("page_no:{}",page_no);
|
||||
pageIsNumber = true;
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("e:{}",e);
|
||||
pageIsNumber = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("pageIsNumber:{}",pageIsNumber);
|
||||
log.error("page_no:{}",page_no);
|
||||
//
|
||||
// log.error("sizeIsNumber:{}",sizeIsNumber);
|
||||
// log.error("noIsNumber:{}",noIsNumber);
|
||||
// log.error("pageNo2:{}",pageNo2);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
|
||||
int pageSize = 100;
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String staffcode = String.valueOf(params.get("staffCode"));
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String workflowId = String.valueOf(params.get("workflowId"));
|
||||
if(StringUtils.isNotBlank(workflowId)){
|
||||
Long workflowid = Long.valueOf(workflowId);
|
||||
Long employeeId = convertStaffCodeService.convEmployeeIdByCode(staffcode);
|
||||
if(employeeId > 0){
|
||||
dataMap = request2CostControlService.queryRequestByWorkflowType(params,workflowid,page_no,pageSize,employeeId);
|
||||
}else{
|
||||
return WeaResult.fail("工号转换,未获取到员工id");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("流程ID获取为空");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("员工工会stffcode为空");
|
||||
}
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbd/workflownew")
|
||||
public class RequestInfoController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(RequestInfoController.class);
|
||||
|
||||
@Autowired
|
||||
Request2CostControlService request2CostControlService;
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/queryRequestByWorkflowType")
|
||||
public WeaResult<Object> queryRequestByWorkflowType(@RequestBody Map<String, Object> params) {
|
||||
log.error("queryRequestByWorkflowType2");
|
||||
|
||||
// int pageNo2 = 1;
|
||||
// int pgeSize2 = 100;
|
||||
// boolean noIsNumber = false;
|
||||
// if(params.containsKey("pageNo")){
|
||||
// String page_no = String.valueOf(params.get("pageNo"));
|
||||
// if(StringUtils.isNotBlank(page_no)){
|
||||
// try {
|
||||
// pageNo2 = Integer.getInteger(page_no);
|
||||
// log.error("pageNo:{}",pageNo2);
|
||||
// noIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// noIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean sizeIsNumber = false;
|
||||
// if(params.containsKey("pageSize")){
|
||||
// String page_size = String.valueOf(params.get("pageSize"));
|
||||
// if(StringUtils.isNotBlank(page_size)){
|
||||
// try {
|
||||
// pgeSize2 = Integer.getInteger(page_size);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
// sizeIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// sizeIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
int page_no = 1;
|
||||
boolean pageIsNumber = false;
|
||||
if(params.containsKey("page")){
|
||||
String page = String.valueOf(params.get("page"));
|
||||
log.error("page:{}",page);
|
||||
if(StringUtils.isNotBlank(page)){
|
||||
try {
|
||||
page_no = Integer.valueOf(page);
|
||||
log.error("page_no:{}",page_no);
|
||||
pageIsNumber = true;
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("e:{}",e);
|
||||
pageIsNumber = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("pageIsNumber2:{}",pageIsNumber);
|
||||
log.error("page_no2:{}",page_no);
|
||||
//
|
||||
// log.error("sizeIsNumber:{}",sizeIsNumber);
|
||||
// log.error("noIsNumber:{}",noIsNumber);
|
||||
// log.error("pageNo2:{}",pageNo2);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
|
||||
int pageSize = 100;
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String staffcode = String.valueOf(params.get("staffCode"));
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String workflowId = String.valueOf(params.get("workflowId"));
|
||||
if(StringUtils.isNotBlank(workflowId)){
|
||||
Long workflowid = Long.valueOf(workflowId);
|
||||
Long employeeId = convertStaffCodeService.convEmployeeIdByCode(staffcode);
|
||||
if(employeeId > 0){
|
||||
dataMap = request2CostControlService.queryRequestByWorkflowType(params,workflowid,page_no,pageSize,employeeId);
|
||||
}else{
|
||||
return WeaResult.fail("工号转换,未获取到员工id");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("流程ID获取为空");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("员工工会stffcode为空");
|
||||
}
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.weaver.seconddev.chapanda.cost.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.cost.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.cost.util.DatabaseUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class ConvertStaffCodeDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConvertStaffCodeDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryEmployeeById(String staffcode){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String dataSql =" select id,username " +
|
||||
" from eteams.employee " +
|
||||
" where job_num = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(staffcode);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}else{
|
||||
recordMap.put("id","");
|
||||
recordMap.put("username","");
|
||||
}
|
||||
}else{
|
||||
recordMap.put("id","");
|
||||
recordMap.put("username","");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
public Long queryEmployeeByCode(String staffcode){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Long employeeId = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String dataSql =" select id,username " +
|
||||
" from eteams.employee " +
|
||||
" where job_num = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(staffcode);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(!recordList.isEmpty()){
|
||||
employeeId = Long.valueOf(String.valueOf(recordList.get(0).get("id")));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface ConvertStaffCodeService {
|
||||
Map<String,Object> convStaffCode(Map<String,Object> paraMap);
|
||||
|
||||
Long convEmployeeIdByCode(String staffcode);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface Request2CostControlService {
|
||||
Map<String, Object> queryRequestByWorkflowType(Map<String, Object> params,Long workflowid,int pageNo,int pageSize,Long employeeId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service.impl;
|
||||
|
||||
import com.weaver.seconddev.chapanda.cost.dao.ConvertStaffCodeDao;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class ConvertStaffCodeServiceImpl implements ConvertStaffCodeService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConvertStaffCodeServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ConvertStaffCodeDao convertStaffCodeDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> convStaffCode(Map<String, Object> paraMap) {
|
||||
String staffcode = String.valueOf(paraMap.get("staffcode"));
|
||||
log.error("staffcode:{}",staffcode);
|
||||
Map<String, Object> dataMap = convertStaffCodeDao.queryEmployeeById(staffcode);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long convEmployeeIdByCode(String staffcode) {
|
||||
log.error("staffcode:{}",staffcode);
|
||||
Long employeeId = convertStaffCodeDao.queryEmployeeByCode(staffcode);
|
||||
log.error("employeeId:{}",employeeId);
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service.impl;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum;
|
||||
import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity;
|
||||
import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity;
|
||||
import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity;
|
||||
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class Request2CostControlServiceImpl implements Request2CostControlService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(Request2CostControlServiceImpl.class);
|
||||
|
||||
@RpcReference(group = "workflow")
|
||||
WflRequestListRest wflRequestListRest;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryRequestByWorkflowType(Map<String, Object> params,Long workflowid,int pageNo,int pageSize,Long employeeId) {
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
log.error("queryRequestByWorkflowType");
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
|
||||
log.error("simpleEmployee:{}",simpleEmployee.getId());
|
||||
|
||||
List<Map<String, Object>> requestList = new ArrayList<Map<String, Object>>();
|
||||
|
||||
Long total = 0L;
|
||||
try{
|
||||
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
|
||||
|
||||
List<Long> workflowIdList = new ArrayList<Long>();
|
||||
workflowIdList.add(workflowid);
|
||||
conditionEntity.setWorkflowIdList(workflowIdList);
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String requestmark = String.valueOf(params.get("requestRemark"));
|
||||
// String staffCode = String.valueOf(params.get("staffCode"));
|
||||
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
// log.error("staffCode:{}",staffCode);
|
||||
|
||||
conditionEntity.setCreater(employeeId);
|
||||
|
||||
if(!"null".equals(requestName) && StringUtils.isNotBlank(requestName)){
|
||||
conditionEntity.setRequestname(requestName);
|
||||
}
|
||||
if(!"null".equals(requestmark) && StringUtils.isNotBlank(requestmark)){
|
||||
conditionEntity.setRequestmark(requestmark);
|
||||
}
|
||||
|
||||
WeaResult<RequestCountInfoPAEntity> requestCountInfo = wflRequestListRest.getRequestCountByTabId(simpleEmployee, RequestListInitDimensionTabEnum.DONE_FINISH.getTabid(),conditionEntity);
|
||||
int countCode = requestCountInfo.getCode();
|
||||
log.error("countCode:{}",countCode);
|
||||
if(countCode == 200){
|
||||
total = requestCountInfo.getData().getCount();
|
||||
}
|
||||
log.error("total:{}",total);
|
||||
dataMap.put("total",total);
|
||||
|
||||
WeaResult<List<RequestListInfoPAEntity>> requestInfoList = wflRequestListRest.getRequestListByTabId(simpleEmployee, RequestListInitDimensionTabEnum.DONE_FINISH.getTabid(), pageNo, pageSize, conditionEntity);
|
||||
int code = requestInfoList.getCode();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
List<RequestListInfoPAEntity> requestListInfo = requestInfoList.getData();
|
||||
log.error("requestListInfo:{}",requestListInfo.size());
|
||||
|
||||
for(int i=0;i<requestListInfo.size();i++){
|
||||
RequestListInfoPAEntity requestListInfoPAEntity = requestListInfo.get(i);
|
||||
String request_Name = requestListInfoPAEntity.getRequestname();
|
||||
String request_remark = requestListInfoPAEntity.getRequestMark();
|
||||
String requestcode = requestListInfoPAEntity.getRequestCode();
|
||||
String appUrl = requestListInfoPAEntity.getAppUrl();
|
||||
String createTime = requestListInfoPAEntity.getCreateTime().toString();
|
||||
String creatorName = requestListInfoPAEntity.getCreatorName();
|
||||
String pcUrl = requestListInfoPAEntity.getPcUrl();
|
||||
|
||||
Map<String, Object> requestMap = new HashMap<String, Object>();
|
||||
requestMap.put("requestName",request_Name);
|
||||
requestMap.put("requestremark",request_remark);
|
||||
requestMap.put("requestcode",requestcode);
|
||||
requestMap.put("appUrl",appUrl);
|
||||
requestMap.put("createTime",createTime);
|
||||
requestMap.put("creatorName",creatorName);
|
||||
requestMap.put("pcUrl",pcUrl);
|
||||
requestList.add(requestMap);
|
||||
}
|
||||
}
|
||||
dataMap.put("data",requestList);
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e.getMessage());
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,422 @@
|
|||
package com.weaver.seconddev.chapanda.cost.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
package com.weaver.seconddev.chapanda.cost.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1167276462243069953";
|
||||
|
||||
public static String dmpHost = "http://internaldataservice-uat.shuxinyc.com";
|
||||
|
||||
public static String gmvUrl = "/api/internal-data-service/hr/shop/gmv";
|
||||
|
||||
public static String token = "xYXL37XoV7xlOnNSdJW44iat";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(FormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryDepartmentList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select code,id from eteams.department and tenant_key=? and delete_type=0" ;
|
||||
log.error("queryDepartmentList--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public String getGmvIdByCode(String code,String formTable,String dataKey){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String dataId = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select id from "+formTable+" and tenant_key=? and delete_type=0 and "+dataKey+"=?" ;
|
||||
log.error("dataSql:{}", dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(code);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
dataId = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.Esb2DmpGetGmvUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2DmpGetGmvCron")
|
||||
public class Esb2DmpGetGmvCron implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2DmpGetGmvCron.class);
|
||||
@Autowired
|
||||
Esb2DmpGetGmvUtil esb2DmpGetGmvUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2DmpGetGmvCron start");
|
||||
String type = String.valueOf(params.get("type"));
|
||||
String startDate = "";
|
||||
String endDate = "";
|
||||
String year = String.valueOf(params.get("year"));
|
||||
if("1".equals(type)){
|
||||
startDate = year+"-01-01";
|
||||
endDate = year+"-12-31";
|
||||
}else{
|
||||
startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).toString();
|
||||
endDate = LocalDate.now().toString();
|
||||
}
|
||||
List<String> ebList = esb2DmpGetGmvUtil.queryGmvList(startDate,endDate);
|
||||
log.error("ebList:{}",ebList.size());
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2DmpGetGmvCron");
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,422 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,367 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class EbuilderOperateUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EbuilderOperateUtils.class);
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
@RpcReference(group = "ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
|
||||
public EBDataChangeResult bacthInsertDbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
log.error("bacthInsertDbForm");
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
// 主表数据参数
|
||||
// Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
// if("uf_yzgl".equals(formTable)){
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(fieldList.get(n).equals("yzzl")){
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, "2"));
|
||||
// }else{
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }else{
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthEditEbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
if (StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)) {
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
/**
|
||||
* 直接通过id更新数据, 即update table set a = '11' where id = 1
|
||||
*/
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 若数据写入后就要从前台看到数据或者立即操作本次写入的数据, 需要调整后置处理为同步 权限处理完成再返回
|
||||
ebDataReqOperation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
// 数据没有找到的时候是否新增数据
|
||||
EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo();
|
||||
ebDataReqOperationInfo.setNeedAdd(true);
|
||||
ebDataReqOperation.setMainData(ebDataReqOperationInfo);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2DmpGetGmvUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2DmpGetGmvUtil.class);
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> queryGmvList(String startDate,String endDate){
|
||||
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
List<Map<String,Object>> addList = new ArrayList<Map<String,Object>>();
|
||||
List<Map<String,Object>> updateList = new ArrayList<Map<String,Object>>();
|
||||
String formTable = "uf_zymdgmv";
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("mdbm");
|
||||
fieldList.add("mdmc");
|
||||
fieldList.add("gmv");
|
||||
fieldList.add("sjsj");
|
||||
fieldList.add("hrmdid");
|
||||
try {
|
||||
Map<String, Object> deptMap = formFieldDao.queryDepartmentList();
|
||||
String msg = doHttpPost(startDate,endDate);
|
||||
log.error("msg:"+msg);
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject msgJson = JSONObject.parseObject(msg);
|
||||
String dataCode = msgJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = msgJson.getJSONArray("data");
|
||||
for(int i = 0; i < dataArray.size(); i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
String mdbm = dataJson.getString("orgCode");
|
||||
String mdmc = dataJson.getString("orgCodeName");
|
||||
String gmv = dataJson.getString("gmv");
|
||||
String sjsj = dataJson.getString("reportDate");
|
||||
String hrmdid = "";
|
||||
Map<String,Object> gmvMap = new HashMap<String,Object>();
|
||||
gmvMap.put("mdbm",mdbm);
|
||||
if(StringUtils.isNotBlank(mdbm)){
|
||||
if(deptMap.containsKey(mdbm)){
|
||||
hrmdid = String.valueOf(deptMap.get(mdbm));
|
||||
}
|
||||
}
|
||||
gmvMap.put("hrmdid",hrmdid);
|
||||
if(StringUtils.isNotBlank(gmv)){
|
||||
if(!"null".equals(gmv) && gmv !=null){
|
||||
gmvMap.put("gmv",gmv);
|
||||
}else{
|
||||
gmvMap.put("gmv","");
|
||||
}
|
||||
}else{
|
||||
gmvMap.put("gmv","");
|
||||
}
|
||||
gmvMap.put("mdmc",mdmc);
|
||||
gmvMap.put("sjsj",sjsj);
|
||||
|
||||
String dataId = formFieldDao.getGmvIdByCode(mdbm,formTable,"mdbm");
|
||||
if(StringUtils.isNotBlank(dataId)){
|
||||
gmvMap.put("id",dataId);
|
||||
updateList.add(gmvMap);
|
||||
}else{
|
||||
addList.add(gmvMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Object> recordMap= formFieldDao.queryTableFormId(formTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
|
||||
if(!addList.isEmpty()){
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
|
||||
Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
for(int i=0;i<addList.size();i++){
|
||||
Map<String,Object> dataMap = addList.get(i);
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataMap.get(fieldList.get(n)).toString();
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
datas.add(ebDataReqDto);
|
||||
}
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(datas,formId,appId);
|
||||
boolean isTrue = ebDataChangeResult.getStatus();
|
||||
if(isTrue){
|
||||
ebList = ebDataChangeResult.getDataIds();
|
||||
}
|
||||
}
|
||||
|
||||
if(!updateList.isEmpty()){
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
for(int i=0;i<addList.size();i++){
|
||||
Map<String,Object> dataMap = addList.get(i);
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
String id = dataMap.get("id").toString();
|
||||
mainData.add(new EBDataReqDetailDto("id", id));
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataMap.get(fieldList.get(n)).toString();
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
datas.add(ebDataReqDto);
|
||||
}
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = ebuilderOperateUtils.bacthEditEbForm(datas,formId,appId);
|
||||
boolean isTrue = ebDataChangeResult.getStatus();
|
||||
if(isTrue){
|
||||
ebList = ebDataChangeResult.getDataIds();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("e:"+e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ebList;
|
||||
}
|
||||
|
||||
|
||||
public String doHttpPost(String startDate,String endDate) {
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startDate", startDate);
|
||||
bodyJson.put("endDate", endDate);
|
||||
// "{\n \"startDate\": \"2025-07-01\",\n \"endDate\": \"2025-07-03\"\n}"
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.dmpHost + Constants.gmvUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", Constants.token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:{}", code);
|
||||
msg = response.body().string();
|
||||
log.error("msg:" + msg);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("e:" + e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.weaver.seconddev.chapanda.esign.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
|
||||
public static String SysUserId = "1167276462243069953";
|
||||
|
||||
public static Long LongSysUserId = 1167276462243069953L;
|
||||
|
||||
public static String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
public static String xTimevaleProjectId = "1001003";
|
||||
public static String eSignHost = "http://110.185.172.132:8086";
|
||||
|
||||
/**
|
||||
* 模板详情接口
|
||||
*/
|
||||
public static String getTemplateInfoUrl = "/esignpro/rest/template/api/getTemplateInfo";
|
||||
|
||||
/**
|
||||
* 查询印章接口
|
||||
*/
|
||||
public static String querySealsUrl = "/V1/seals/innerOrgansSeals/list";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static String sealTable = "uf_yzgl";
|
||||
|
||||
/***
|
||||
* 获取模板预览接口
|
||||
*/
|
||||
public static String previewUrl = "/V1/signDocs/getPreviewUrl";
|
||||
|
||||
/***
|
||||
* 生成模板文件接口
|
||||
*/
|
||||
public static String templateDocUrl = "/esignpro/rest/template/api/buildTemplateDoc";
|
||||
|
||||
/***
|
||||
* 查询模板接口
|
||||
*/
|
||||
public static String queryTemplateUrl = "/V1/template/list";
|
||||
|
||||
|
||||
public static String templateTable = "uf_dzqmbgl";
|
||||
|
||||
public static String templateTableZdb = "uf_dzqmbgl_zdb";
|
||||
|
||||
public static String qrDocSwitcher = "false";
|
||||
|
||||
public static String signFileFormat = "PDF";
|
||||
|
||||
public static String partyBaccountType = "2";
|
||||
|
||||
public static String autoSign = "false";
|
||||
|
||||
public static int edgePosition = 1;
|
||||
|
||||
public static int edgeScope = 0;
|
||||
|
||||
public static int sealType = 0;
|
||||
|
||||
public static String partyAaccountType = "1";
|
||||
|
||||
public static String externalpersonUrl = "/V1/accounts/outerAccounts/simpleCreate";
|
||||
|
||||
|
||||
public static String signFlowsUrl = "/V1/signFlows/create";
|
||||
|
||||
public static String fileDownloadUrl = "/V1/files/getDownloadUrl";
|
||||
public static String getSignFlowDocUrls = "/V1/signFlows/getSignFlowDocUrls";
|
||||
|
||||
|
||||
public static String getDownloadUrl = "/esignproweb/rest/file-system/operation/download";
|
||||
|
||||
public static Long htwjFolderId = 3875375598175452527L;
|
||||
|
||||
public static String reminderRequestUrl = "/esignpro/rest/process/reminder";
|
||||
|
||||
|
||||
public static String callbackUrl = "https://hrtest.chabaidao.com/papi/secondev/cbd/signflow/doCallBack";
|
||||
|
||||
public static Long callbacFolderId = 2415515046193663118L;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.weaver.seconddev.chapanda.esign.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.esign.util.CommonUtils;
|
||||
import com.weaver.seconddev.chapanda.esign.service.SealTemplateService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbd/eseal")
|
||||
public class SealTemplateController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SealTemplateController.class);
|
||||
|
||||
@Autowired
|
||||
SealTemplateService sealTemplateService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
/***
|
||||
* 电子签名模板预览接口
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/queryPreviewUrl")
|
||||
public WeaResult<Object> queryPreviewUrl(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> dataMap = new HashMap<String,Object>();
|
||||
String templateId = request.getParameter("templateId");
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
|
||||
if(StringUtils.isNotBlank(templateId)){
|
||||
dataMap = sealTemplateService.queryPreviewUrl(templateId,paraMap);
|
||||
}else{
|
||||
return WeaResult.fail(500,"模板ID为空");
|
||||
}
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/queryTemplateField")
|
||||
public WeaResult<Object> queryTemplateField(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
|
||||
String templateId = request.getParameter("templateId");
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
|
||||
if(StringUtils.isNotBlank(templateId)){
|
||||
dataList = sealTemplateService.queryTemplateField(templateId,paraMap);
|
||||
}else{
|
||||
return WeaResult.fail(500,"模板ID为空");
|
||||
}
|
||||
return WeaResult.success(dataList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.weaver.seconddev.chapanda.esign.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.CallbackUrlBean;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.FinishDocUrlBean;
|
||||
import com.weaver.seconddev.chapanda.esign.service.SignFlowsCallBackService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/papi/secondev/cbd/signflow")
|
||||
public class SignFlowsCallBackController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SignFlowsCallBackController.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
SignFlowsCallBackService signFlowsCallBackService;
|
||||
|
||||
/***
|
||||
* 回调接口
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/doCallBack")
|
||||
public JSONObject doCallBack(@RequestBody CallbackUrlBean callbackUrlBean) throws IOException {
|
||||
|
||||
String action = callbackUrlBean.getAction();
|
||||
log.error("action:{}",action);
|
||||
String flowId = String.valueOf(callbackUrlBean.getFlowId());
|
||||
log.error("flowId:{}",flowId);
|
||||
String flowType = callbackUrlBean.getFlowType();
|
||||
log.error("flowType:{}",flowType);
|
||||
int status = callbackUrlBean.getStatus();
|
||||
log.error("status:{}",status);
|
||||
String createTime = callbackUrlBean.getCreateTime();
|
||||
log.error("createTime:{}",createTime);
|
||||
String endTime = callbackUrlBean.getEndTime();
|
||||
log.error("endTime:{}",endTime);
|
||||
|
||||
List<FinishDocUrlBean> finishDocUrlBeans = callbackUrlBean.getFinishDocUrlBeans();
|
||||
for (int i = 0; i < finishDocUrlBeans.size(); i++) {
|
||||
FinishDocUrlBean finishDocUrlBean = finishDocUrlBeans.get(i);
|
||||
String docFileKey = finishDocUrlBean.getDocFileKey();
|
||||
log.error("docFileKey:{}",docFileKey);
|
||||
String downloadDocUrl = finishDocUrlBean.getDownloadDocUrl();
|
||||
log.error("downloadDocUrl:{}",downloadDocUrl);
|
||||
String finishFileKey = finishDocUrlBean.getFinishFileKey();
|
||||
log.error("finishFileKey:{}",finishFileKey);
|
||||
}
|
||||
|
||||
if("SIGN_FLOW_FINISH".equals(action)){
|
||||
log.error("action22:{}",action);
|
||||
if("Common".equals(flowType)){
|
||||
log.error("flowType22:{}",flowType);
|
||||
if(status == 2){
|
||||
log.error("status22:{}",status);
|
||||
if(StringUtils.isNotEmpty(flowId)){
|
||||
log.error("flowId22:{}",flowId);
|
||||
if(finishDocUrlBeans.size()>0){
|
||||
FinishDocUrlBean finishDocUrlBean = finishDocUrlBeans.get(0);
|
||||
String docFileKey = finishDocUrlBean.getDocFileKey();
|
||||
String downloadDocUrl = finishDocUrlBean.getDownloadDocUrl();
|
||||
String finishFileKey = finishDocUrlBean.getFinishFileKey();
|
||||
log.error("downloadDocUrl:{}",downloadDocUrl);
|
||||
log.error("finishFileKey:{}",finishFileKey);
|
||||
if(StringUtils.isNotBlank(downloadDocUrl)){
|
||||
signFlowsCallBackService.creatDocFile(flowId,downloadDocUrl,finishFileKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("errCode","0");
|
||||
dataJson.put("msg","成功");
|
||||
|
||||
return dataJson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试接口
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
package com.weaver.seconddev.chapanda.esign.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.esign.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(FormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key")).toLowerCase();
|
||||
String id = String.valueOf(recordMap.get("id")).toLowerCase();
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryDepartmentList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select code,id from eteams.department and tenant_key=? and delete_type=0" ;
|
||||
log.error("queryDepartmentList--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public String queryEmailByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String gryx = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select k.gryx from eteams.employee t\n" +
|
||||
" inner join eteams.ft_1152026012537184302 k on k.id = t.formdata\n" +
|
||||
" where t.id=? " +
|
||||
" and t.tenant_key=? \n" +
|
||||
" and t.delete_type=0" +
|
||||
" and k.tenant_key=? \n" +
|
||||
" and k.delete_type=0";
|
||||
|
||||
log.error("queryEmailByEmployeeId--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryEmailByEmployeeId:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
gryx = String.valueOf(recordList.get(0).get("gryx"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryEmailByEmployeeId:e:" + e);
|
||||
}
|
||||
return gryx;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryDepartmentData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select code,id from eteams.department where status = 1 " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryEmployeeData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select job_num,id from eteams.employee where tenant_key=? and delete_type = 0" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String job_num = String.valueOf(recordMap.get("job_num"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(job_num,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public Long queryTableFormIdByEb(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Long form_id = 0L;
|
||||
|
||||
try{
|
||||
String dataSql =" select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
form_id = Long.valueOf(String.valueOf(recordMap.get("form_id")));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return form_id;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> queryDetailTableField(String mainTable,String detailTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in(select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id in(select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? )\n"+
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(mainTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(detailTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDetailTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package com.weaver.seconddev.chapanda.esign.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.esign.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SealTemplateDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(SealTemplateDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryTemplateDataByTemplateId(String templateId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String dataid = "";
|
||||
try{
|
||||
String dataSql =" select id from "+Constants.templateTable+" where mbid=? and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(templateId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
if(recordList.get(0).containsKey("id")){
|
||||
dataid = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return dataid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String,Object>> queryTemplateFieldByTemplateId(String templateId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
String dataSql =" select k.zdm ,k.zdlx ,k.zdlx_obj ,k.zdz ,k.zdmc \n" +
|
||||
" from uf_dzqmbgl t\n" +
|
||||
" inner join uf_dzqmbgl_zdb k on k.form_data_id = t.form_data_id \n" +
|
||||
" where t.mbid=? and t.tenant_key=? and t.delete_type=0 and k.tenant_key=? and k.delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(templateId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}", recordList.size());
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryValueByConfig(String dataSql){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String dataid = "";
|
||||
try{
|
||||
|
||||
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, dataSql);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
dataid = String.valueOf(recordMap.values().stream().findFirst().orElse(null));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return dataid;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,Object>> queryTemplateFieldByType(String templateId,String type){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
String dataSql =" select k.zdm ,k.zdlx ,k.zdlx_obj ,k.zdz ,k.zdmc,k.zdz as rc \n" +
|
||||
" from uf_dzqmbgl t\n" +
|
||||
" inner join uf_dzqmbgl_zdb k on k.form_data_id = t.form_data_id \n" +
|
||||
" where t.mbid=? and t.tenant_key=? and k.zdlx in("+type+") " +
|
||||
" and t.delete_type=0 and k.tenant_key=? and k.delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(templateId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}", recordList.size());
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.weaver.seconddev.chapanda.esign.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.esign.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SealsManageDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(SealsManageDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryLegalEntityList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
String dataSql =" select bh,mc from uf_legal_entity where tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sealid
|
||||
* @return
|
||||
*/
|
||||
public String querySealsDataBySealId(String sealid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String dataid = "";
|
||||
try{
|
||||
String dataSql =" select id from " + Constants.sealTable+
|
||||
" where sealid = ? and tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(sealid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
dataid = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return dataid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.weaver.seconddev.chapanda.esign.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.esign.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SignFlowCallBackDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(SignFlowCallBackDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryFlowInfo(String flowId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select form_data_id,glhtlylc from uf_jcl_rshtgl where qslcid =? and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(flowId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
dataMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public String queryRequestName(String requestid){
|
||||
String groupId = "weaver-workflow-report-serviceworkflowreport";
|
||||
String sourceType = "LOGIC";
|
||||
String requestname = "";
|
||||
try{
|
||||
String dataSql =" select requestname from wfc_requestbase wr where requestid =? and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(requestid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
requestname = String.valueOf(recordList.get(0).get("requestname"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return requestname;
|
||||
}
|
||||
|
||||
|
||||
public void updateFormTableInfo(String form_data_id,Long fileid,String finishFileKey){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
try{
|
||||
String dataSql =" update uf_jcl_rshtgl set wjid='"+finishFileKey+"',fj_6pgb='"+String.valueOf(fileid)+"' where form_data_id ='"+form_data_id+"' and tenant_key='"+Constants.TENANT_KEY+"' \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
Map<String, Object> result = databaseUtils.executeUpdate(sourceType, groupId, dataSql);
|
||||
for (Map.Entry<String, Object> entry : result.entrySet()) {
|
||||
log.error(entry.getKey() + ": " + String.valueOf(entry.getValue()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.weaver.seconddev.chapanda.esign.entity;
|
||||
|
||||
/**
|
||||
* packageName com.weaver.seconddev.chapanda.esign.entity
|
||||
*
|
||||
* @ClassName AccountInfoBean
|
||||
* @Author shil
|
||||
* @Date 2025/8/13 14:43
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
public class AccountInfoBean {
|
||||
String accountId;
|
||||
String accountUid;
|
||||
String organizeNo;
|
||||
String authOrgId;
|
||||
String authOrgName;
|
||||
String name;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.weaver.seconddev.chapanda.esign.entity;
|
||||
|
||||
/**
|
||||
* packageName com.weaver.seconddev.chapanda.esign.entity
|
||||
*
|
||||
* @ClassName CallBackDto
|
||||
* @Author shil
|
||||
* @Date 2025/8/13 10:13
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
public class CallBackBean {
|
||||
CallbackUrlBean callbackUrlBean;
|
||||
String url;
|
||||
|
||||
public CallbackUrlBean getCallbackUrlBean() {
|
||||
return callbackUrlBean;
|
||||
}
|
||||
|
||||
public void setCallbackUrlBean(CallbackUrlBean callbackUrlBean) {
|
||||
this.callbackUrlBean = callbackUrlBean;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CallBackBean{" +
|
||||
"callbackUrlBean=" + callbackUrlBean +
|
||||
", url='" + url + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.weaver.seconddev.chapanda.esign.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* packageName com.weaver.seconddev.chapanda.esign.entity
|
||||
*
|
||||
* @ClassName CallBackDto
|
||||
* @Author shil
|
||||
* @Date 2025/8/13 10:13
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
public class CallbackUrlBean {
|
||||
String action;
|
||||
String createTime;
|
||||
String endTime;
|
||||
List<FinishDocUrlBean> finishDocUrlBeans;
|
||||
int flowId;
|
||||
String flowType;
|
||||
String resultDescription;
|
||||
int status;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public List<FinishDocUrlBean> getFinishDocUrlBeans() {
|
||||
return finishDocUrlBeans;
|
||||
}
|
||||
|
||||
public void setFinishDocUrlBeans(List<FinishDocUrlBean> finishDocUrlBeans) {
|
||||
this.finishDocUrlBeans = finishDocUrlBeans;
|
||||
}
|
||||
|
||||
public int getFlowId() {
|
||||
return flowId;
|
||||
}
|
||||
|
||||
public void setFlowId(int flowId) {
|
||||
this.flowId = flowId;
|
||||
}
|
||||
|
||||
public String getFlowType() {
|
||||
return flowType;
|
||||
}
|
||||
|
||||
public void setFlowType(String flowType) {
|
||||
this.flowType = flowType;
|
||||
}
|
||||
|
||||
public String getResultDescription() {
|
||||
return resultDescription;
|
||||
}
|
||||
|
||||
public void setResultDescription(String resultDescription) {
|
||||
this.resultDescription = resultDescription;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CallbackUrlBean{" +
|
||||
"action='" + action + '\'' +
|
||||
", createTime='" + createTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
", finishDocUrlBeans=" + finishDocUrlBeans +
|
||||
", flowId=" + flowId +
|
||||
", flowType='" + flowType + '\'' +
|
||||
", resultDescription='" + resultDescription + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.weaver.seconddev.chapanda.esign.entity;
|
||||
|
||||
/**
|
||||
* packageName com.weaver.seconddev.chapanda.esign.entity
|
||||
*
|
||||
* @ClassName finishDocUrlBeans
|
||||
* @Author shil
|
||||
* @Date 2025/8/13 10:13
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
public class FinishDocUrlBean {
|
||||
String docFileKey;
|
||||
String downloadDocUrl;
|
||||
String finishFileKey;
|
||||
|
||||
public String getDocFileKey() {
|
||||
return docFileKey;
|
||||
}
|
||||
|
||||
public void setDocFileKey(String docFileKey) {
|
||||
this.docFileKey = docFileKey;
|
||||
}
|
||||
|
||||
public String getDownloadDocUrl() {
|
||||
return downloadDocUrl;
|
||||
}
|
||||
|
||||
public void setDownloadDocUrl(String downloadDocUrl) {
|
||||
this.downloadDocUrl = downloadDocUrl;
|
||||
}
|
||||
|
||||
public String getFinishFileKey() {
|
||||
return finishFileKey;
|
||||
}
|
||||
|
||||
public void setFinishFileKey(String finishFileKey) {
|
||||
this.finishFileKey = finishFileKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishDocUrlBean{" +
|
||||
"docFileKey='" + docFileKey + '\'' +
|
||||
", downloadDocUrl='" + downloadDocUrl + '\'' +
|
||||
", finishFileKey='" + finishFileKey + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.weaver.seconddev.chapanda.esign.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* packageName com.weaver.seconddev.chapanda.esign.entity
|
||||
*
|
||||
* @ClassName OkHttpDto
|
||||
* @Author shil
|
||||
* @Date 2025/8/12 15:37
|
||||
* @Description TODO
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class OkHttpDto {
|
||||
|
||||
int responseCode;
|
||||
String responseBody;
|
||||
|
||||
int dataCode;
|
||||
String dataMsg;
|
||||
|
||||
JSONObject dataJson;
|
||||
|
||||
public int getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public void setResponseCode(int responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public String getResponseBody() {
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
public void setResponseBody(String responseBody) {
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
|
||||
public int getDataCode() {
|
||||
return dataCode;
|
||||
}
|
||||
|
||||
public void setDataCode(int dataCode) {
|
||||
this.dataCode = dataCode;
|
||||
}
|
||||
|
||||
public String getDataMsg() {
|
||||
return dataMsg;
|
||||
}
|
||||
|
||||
public void setDataMsg(String dataMsg) {
|
||||
this.dataMsg = dataMsg;
|
||||
}
|
||||
|
||||
public JSONObject getDataJson() {
|
||||
return dataJson;
|
||||
}
|
||||
|
||||
public void setDataJson(JSONObject dataJson) {
|
||||
this.dataJson = dataJson;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.OkHttpDto;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignApplyRequest4OrgainzeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignCreateRequest4OrganizeAction")
|
||||
public class Esb2EsignCreateRequest4OrganizeAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignCreateRequest4OrganizeAction.class);
|
||||
@Autowired
|
||||
Esb2EsignApplyRequest4OrgainzeUtil esb2EsignApplyRequest4OrgainzeUtil;
|
||||
|
||||
// @Autowired
|
||||
// private Esb2EsignPreviewUrlUtil esb2EsignPreviewUrlUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestname = String.valueOf(params.get("requestname"));
|
||||
String sealId = String.valueOf(params.get("sealId"));
|
||||
String docFilekey = String.valueOf(params.get("docFilekey"));
|
||||
String docName = String.valueOf(params.get("docName"));
|
||||
String creditCode = String.valueOf(params.get("creditCode"));
|
||||
String qsrJobNum = String.valueOf(params.get("qsrJobNum"));
|
||||
String templateId = String.valueOf(params.get("templateId"));
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("requestname:{}",requestname);
|
||||
log.error("sealId:{}",sealId);
|
||||
log.error("docFilekey:{}",docFilekey);
|
||||
log.error("docName:{}",docName);
|
||||
log.error("creditCode:{}",creditCode);
|
||||
log.error("qsrJobNum:{}",qsrJobNum);
|
||||
log.error("templateId:{}",templateId);
|
||||
|
||||
if(StringUtils.isBlank(templateId)){
|
||||
return WeaResult.fail(500,"参数模板ID为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(creditCode)){
|
||||
return WeaResult.fail(500,"参数统一社会信用代码为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(docFilekey)){
|
||||
return WeaResult.fail(500,"参数签署文件为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(sealId)){
|
||||
return WeaResult.fail(500,"参数签署文件印章为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(qsrJobNum)){
|
||||
return WeaResult.fail(500,"参数签署人工号为空");
|
||||
}
|
||||
|
||||
String signFlowId = "";
|
||||
String signUrls = "";
|
||||
String accountIds = "";
|
||||
String uniqueIds = "";
|
||||
String fileKeys = "";
|
||||
|
||||
if(StringUtils.isNotBlank(templateId)){
|
||||
// JSONObject dataJson = esb2EsignApplyRequest4OrgainzeUtil.applyRequest(requestid,requestname,templateId,sealId,docFilekey,docName,creditCode,qsrJobNum);
|
||||
OkHttpDto okHttpDto = esb2EsignApplyRequest4OrgainzeUtil.applyRequest(requestid,requestname,templateId,sealId,docFilekey,docName,creditCode,qsrJobNum);
|
||||
if(okHttpDto.getResponseCode() == 200){
|
||||
if(okHttpDto.getDataCode() == 0){
|
||||
JSONObject dataJson = okHttpDto.getDataJson();
|
||||
log.error("dataJson:{}",dataJson.toJSONString());
|
||||
signFlowId = dataJson.getString("signFlowId");
|
||||
signUrls = dataJson.getString("signUrls");
|
||||
accountIds = dataJson.getString("accountIds");
|
||||
uniqueIds = dataJson.getString("uniqueIds");
|
||||
fileKeys = dataJson.getString("fileKeys");
|
||||
}else{
|
||||
return WeaResult.fail(500,"创建签署流程异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"签署流程接口异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
log.error("signFlowId:{}",signFlowId);
|
||||
log.error("signUrls:{}",signUrls);
|
||||
log.error("accountIds:{}",accountIds);
|
||||
log.error("uniqueIds:{}",uniqueIds);
|
||||
log.error("fileKeys:{}",fileKeys);
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(fileKeys)){
|
||||
return WeaResult.fail(500,"获取签署文件失败");
|
||||
}
|
||||
|
||||
// String preViewUrl = "";
|
||||
// if(StringUtils.isNotBlank(fileKeys)){
|
||||
//// preViewUrl = esb2EsignPreviewUrlUtil.queryPreviewUrl(fileKeys);
|
||||
// OkHttpDto preOkHttpDto = esb2EsignPreviewUrlUtil.queryPreviewUrl(fileKeys);
|
||||
// if(preOkHttpDto.getResponseCode() == 200){
|
||||
// if(preOkHttpDto.getDataCode() == 0){
|
||||
// JSONObject preJson = preOkHttpDto.getDataJson();
|
||||
// if(preJson.containsKey("preViewUrl")){
|
||||
// preViewUrl = preJson.getString("preViewUrl");
|
||||
// }
|
||||
// }else{
|
||||
// return WeaResult.fail(500,"获取预览地址异常,"+preOkHttpDto.getDataMsg());
|
||||
// }
|
||||
// }else{
|
||||
// return WeaResult.fail(500,"文件预览地址接口异常,"+preOkHttpDto.getDataMsg());
|
||||
// }
|
||||
// }
|
||||
// log.error("preViewUrl:{}",preViewUrl);
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("signFlowId",signFlowId);
|
||||
actionMap.put("accountIds",accountIds);
|
||||
actionMap.put("signUrls",signUrls);
|
||||
actionMap.put("uniqueIds",uniqueIds);
|
||||
actionMap.put("fileKeys",fileKeys);
|
||||
// actionMap.put("preViewUrl",preViewUrl);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.OkHttpDto;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignApplyRequestUtil;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignPreviewUrlUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignCreateRequest4PartiesAction")
|
||||
public class Esb2EsignCreateRequest4PartiesAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignCreateRequest4PartiesAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2EsignApplyRequestUtil esb2EsignApplyRequestUtil;
|
||||
|
||||
@Autowired
|
||||
private Esb2EsignPreviewUrlUtil esb2EsignPreviewUrlUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestname = String.valueOf(params.get("requestname"));
|
||||
String sealId = String.valueOf(params.get("sealId"));
|
||||
String docFilekey = String.valueOf(params.get("docFilekey"));
|
||||
String docName = String.valueOf(params.get("docName"));
|
||||
String creditCode = String.valueOf(params.get("creditCode"));
|
||||
|
||||
String employeeMobile = String.valueOf(params.get("employeeMobile"));
|
||||
String qsrJobNum = String.valueOf(params.get("qsrJobNum"));
|
||||
String templateId = String.valueOf(params.get("templateId"));
|
||||
|
||||
if(StringUtils.isBlank(templateId)){
|
||||
return WeaResult.fail(500,"参数模板ID为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(creditCode)){
|
||||
return WeaResult.fail(500,"参数统一社会信用代码为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(docFilekey)){
|
||||
return WeaResult.fail(500,"参数签署文件为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(sealId)){
|
||||
return WeaResult.fail(500,"参数签署文件印章为空");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(qsrJobNum)){
|
||||
return WeaResult.fail(500,"参数签署人工号为空");
|
||||
}
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("requestname:{}",requestname);
|
||||
log.error("sealId:{}",sealId);
|
||||
log.error("docFilekey:{}",docFilekey);
|
||||
log.error("docName:{}",docName);
|
||||
log.error("creditCode:{}",creditCode);
|
||||
log.error("employeeMobile:{}",employeeMobile);
|
||||
log.error("qsrJobNum:{}",qsrJobNum);
|
||||
|
||||
String signFlowId = "";
|
||||
String signUrls = "";
|
||||
String accountIds = "";
|
||||
String uniqueIds = "";
|
||||
String fileKeys = "";
|
||||
|
||||
if(StringUtils.isNotBlank(templateId)){
|
||||
OkHttpDto okHttpDto = esb2EsignApplyRequestUtil.applyRequest(requestid,requestname,employeeMobile,templateId,sealId,docFilekey,docName,creditCode,qsrJobNum);
|
||||
if(okHttpDto.getResponseCode() == 200){
|
||||
if(okHttpDto.getDataCode() == 0){
|
||||
JSONObject dataJson = okHttpDto.getDataJson();
|
||||
signFlowId = dataJson.getString("signFlowId");
|
||||
signUrls = dataJson.getString("signUrls");
|
||||
accountIds = dataJson.getString("accountIds");
|
||||
uniqueIds = dataJson.getString("uniqueIds");
|
||||
fileKeys = dataJson.getString("fileKeys");
|
||||
}else{
|
||||
return WeaResult.fail(500,"创建签署流程异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"签署流程接口异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
|
||||
log.error("signFlowId:{}",signFlowId);
|
||||
log.error("signUrls:{}",signUrls);
|
||||
log.error("accountIds:{}",accountIds);
|
||||
log.error("uniqueIds:{}",uniqueIds);
|
||||
log.error("fileKeys:{}",fileKeys);
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(fileKeys)){
|
||||
return WeaResult.fail(500,"获取签署文件失败");
|
||||
}
|
||||
|
||||
String preViewUrl = "";
|
||||
if(StringUtils.isNotBlank(fileKeys)){
|
||||
OkHttpDto preOkHttpDto = esb2EsignPreviewUrlUtil.queryPreviewUrl(fileKeys);
|
||||
if(preOkHttpDto.getResponseCode() == 200){
|
||||
if(preOkHttpDto.getDataCode() == 0){
|
||||
JSONObject preJson = preOkHttpDto.getDataJson();
|
||||
if(preJson.containsKey("preViewUrl")){
|
||||
preViewUrl = preJson.getString("preViewUrl");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"获取签署文件预览地址异常,"+preOkHttpDto.getDataMsg());
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"签署文件预览地址接口异常,"+preOkHttpDto.getDataMsg());
|
||||
}
|
||||
}
|
||||
log.error("preViewUrl:{}",preViewUrl);
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("signFlowId",signFlowId);
|
||||
actionMap.put("accountIds",accountIds);
|
||||
actionMap.put("signUrls",signUrls);
|
||||
actionMap.put("uniqueIds",uniqueIds);
|
||||
actionMap.put("fileKeys",fileKeys);
|
||||
actionMap.put("preViewUrl",preViewUrl);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.OkHttpDto;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignApplyRequestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignCreateRequestAction")
|
||||
public class Esb2EsignCreateRequestAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignCreateRequestAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2EsignApplyRequestUtil esb2EsignApplyRequestUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestname = String.valueOf(params.get("requestname"));
|
||||
String sealId = String.valueOf(params.get("sealId"));
|
||||
String docFilekey = String.valueOf(params.get("docFilekey"));
|
||||
String docName = String.valueOf(params.get("docName"));
|
||||
String creditCode = String.valueOf(params.get("creditCode"));
|
||||
|
||||
String employeeMobile = String.valueOf(params.get("employeeMobile"));
|
||||
String qsrJobNum = String.valueOf(params.get("qsrJobNum"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("requestname:{}",requestname);
|
||||
log.error("sealId:{}",sealId);
|
||||
log.error("docFilekey:{}",docFilekey);
|
||||
log.error("docName:{}",docName);
|
||||
log.error("creditCode:{}",creditCode);
|
||||
log.error("employeeMobile:{}",employeeMobile);
|
||||
log.error("qsrJobNum:{}",qsrJobNum);
|
||||
|
||||
String signFlowId = "";
|
||||
String signUrls = "";
|
||||
String accountIds = "";
|
||||
String uniqueIds = "";
|
||||
String fileKeys = "";
|
||||
String templateId = String.valueOf(params.get("templateId"));
|
||||
if(StringUtils.isNotBlank(templateId)){
|
||||
OkHttpDto okHttpDto = esb2EsignApplyRequestUtil.applyRequest(requestid,requestname,employeeMobile,templateId,sealId,docFilekey,docName,creditCode,qsrJobNum);
|
||||
if(okHttpDto.getResponseCode() == 200){
|
||||
if(okHttpDto.getDataCode() == 0){
|
||||
JSONObject dataJson = okHttpDto.getDataJson();
|
||||
signFlowId = dataJson.getString("signFlowId");
|
||||
signUrls = dataJson.getString("signUrls");
|
||||
accountIds = dataJson.getString("accountIds");
|
||||
uniqueIds = dataJson.getString("uniqueIds");
|
||||
fileKeys = dataJson.getString("fileKeys");
|
||||
}else{
|
||||
return WeaResult.fail(500,"创建签署流程异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"签署流程接口异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
|
||||
log.error("signFlowId:{}",signFlowId);
|
||||
log.error("signUrls:{}",signUrls);
|
||||
log.error("accountIds:{}",accountIds);
|
||||
log.error("uniqueIds:{}",uniqueIds);
|
||||
log.error("fileKeys:{}",fileKeys);
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(fileKeys)){
|
||||
return WeaResult.fail(500,"用印申请失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("signFlowId",signFlowId);
|
||||
actionMap.put("accountIds",accountIds);
|
||||
actionMap.put("signUrls",signUrls);
|
||||
actionMap.put("uniqueIds",uniqueIds);
|
||||
actionMap.put("fileKeys",fileKeys);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.entity.OkHttpDto;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignCreateUserUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignCreateUserAction")
|
||||
public class Esb2EsignCreateUserAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignCreateUserAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2EsignCreateUserUtil esb2EsignCreateUserUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String mobile = String.valueOf(params.get("mobile"));
|
||||
String name = String.valueOf(params.get("name"));
|
||||
|
||||
log.error("mobile:{}",mobile);
|
||||
log.error("name:{}",name);
|
||||
|
||||
if(StringUtils.isBlank(mobile)){
|
||||
return WeaResult.fail(500,"入参手机号为空");
|
||||
}
|
||||
if(StringUtils.isBlank(name)){
|
||||
return WeaResult.fail(500,"入参姓名为空");
|
||||
}
|
||||
|
||||
String esignAccountId = "";
|
||||
String uniqueId = "";
|
||||
if(StringUtils.isNotBlank(mobile) && StringUtils.isNotBlank(name)){
|
||||
OkHttpDto okHttpDto = esb2EsignCreateUserUtil.createUser(name,mobile);
|
||||
if(okHttpDto.getResponseCode() == 200){
|
||||
if(okHttpDto.getDataCode() == 0){
|
||||
JSONObject dataJson = okHttpDto.getDataJson();
|
||||
if(dataJson.containsKey("esignAccountId")){
|
||||
esignAccountId = dataJson.getString("esignAccountId");
|
||||
}
|
||||
if(dataJson.containsKey("uniqueId")){
|
||||
uniqueId = dataJson.getString("uniqueId");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"E签宝用户创建异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail(500,"E签宝用户创建接口异常,"+okHttpDto.getDataMsg());
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(esignAccountId)){
|
||||
return WeaResult.fail(500,"e签宝创建用户失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("esignAccountId",esignAccountId);
|
||||
actionMap.put("mobile",mobile);
|
||||
actionMap.put("uniqueId",uniqueId);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue