#chabaodao-5# 0917统一提交

This commit is contained in:
shilei 2025-09-17 16:21:49 +08:00
parent 27732527f4
commit 65161e83e0
47 changed files with 2335 additions and 410 deletions

View File

@ -1,14 +1,13 @@
package com.weaver.seconddev.chapanda.hrm.constant;
import com.weaver.workflow.common.constant.list.requestlist.RequestListDimensionEnum;
public enum DownLoadTypeEnum {
INFORMATION("0","info", "info","签署文件下载"),
CONTRACT("1","contract", "contract","签署文件下载"),
INCOME("2","income", "income","签署文件下载"),
EMPLOYMENT("3","employment", "employment","签署文件下载"),
RESIGN("4","resign", "resign","签署文件下载");
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;
@ -17,11 +16,14 @@ public enum DownLoadTypeEnum {
private String fileName;
private DownLoadTypeEnum(String code,String type, String path,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() {
@ -55,4 +57,12 @@ public enum DownLoadTypeEnum {
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,113 @@
package com.weaver.seconddev.chapanda.hrm.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.hrm.service.EstablishmentManagerService;
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.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/secondev/chapanda/hrm/est")
public class EstablishmentManagerController {
private final Logger log = LoggerFactory.getLogger(EstablishmentManagerController.class);
@Autowired
private EstablishmentManagerService establishmentManagerService;
@WeaPermission(publicPermission = true)
@GetMapping("/quertEstId")
public WeaResult<Object> quertEstId(HttpServletRequest request, HttpServletResponse response){
String orgId = String.valueOf(request.getParameter("orgId"));
log.error("orgId:{}",orgId);
String planId = String.valueOf(request.getParameter("planId"));
String year = String.valueOf(request.getParameter("year"));
String month = String.valueOf(request.getParameter("month"));
String orgName = String.valueOf(request.getParameter("orgName"));
String estCount = String.valueOf(request.getParameter("estCount"));
String estCountWithSub = String.valueOf(request.getParameter("estCountWithSub"));
Map<String,Object> dataMap = new HashMap<String,Object>();
String id = establishmentManagerService.quertEstId(orgId,planId,year,month);
dataMap.put("id",id);
dataMap.put("orgId",orgId);
dataMap.put("planId",planId);
dataMap.put("year",year);
dataMap.put("month",month);
dataMap.put("overCtrl","STRONG");
dataMap.put("estCount",estCount);
dataMap.put("estCountWithSub",estCountWithSub);
dataMap.put("syncToSup",true);
dataMap.put("onlyCheck",true);
JSONObject dataJson = new JSONObject();
dataJson.put("data",dataMap);
dataJson.put("orgName",orgName);
return WeaResult.success(dataJson);
}
@WeaPermission(publicPermission = true)
@GetMapping("/queryEstId4Check")
public WeaResult<Object> queryEstId4Check(HttpServletRequest request, HttpServletResponse response){
String orgId = String.valueOf(request.getParameter("orgId"));
log.error("orgId:{}",orgId);
String planId = String.valueOf(request.getParameter("planId"));
String year = String.valueOf(request.getParameter("year"));
String month = String.valueOf(request.getParameter("month"));
Map<String,Object> dataMap = new HashMap<String,Object>();
String id = establishmentManagerService.quertEstId(orgId,planId,year,month);
dataMap.put("id",id);
return WeaResult.success(dataMap);
}
@WeaPermission(publicPermission = true)
@GetMapping("/queryEstId4Save")
public WeaResult<Object> queryEstId4Save(HttpServletRequest request, HttpServletResponse response){
String orgId = String.valueOf(request.getParameter("orgId"));
log.error("orgId:{}",orgId);
String planId = String.valueOf(request.getParameter("planId"));
String year = String.valueOf(request.getParameter("year"));
String month = String.valueOf(request.getParameter("month"));
Map<String,Object> dataMap = new HashMap<String,Object>();
String id = establishmentManagerService.quertEstId(orgId,planId,year,month);
String count = establishmentManagerService.queryEstTotalByOrgId(orgId,planId,year,month);
dataMap.put("count",count);
dataMap.put("id",id);
return WeaResult.success(dataMap);
}
@WeaPermission(publicPermission = true)
@GetMapping("/queryEstTotalByOrgId")
public WeaResult<Object> queryEstTotalByOrgId(HttpServletRequest request, HttpServletResponse response){
String orgId = String.valueOf(request.getParameter("orgId"));
log.error("orgId:{}",orgId);
String planId = String.valueOf(request.getParameter("planId"));
String year = String.valueOf(request.getParameter("year"));
String month = String.valueOf(request.getParameter("month"));
Map<String,Object> dataMap = new HashMap<String,Object>();
String count = establishmentManagerService.queryEstTotalByOrgId(orgId,planId,year,month);
dataMap.put("count",count);
return WeaResult.success(dataMap);
}
@WeaPermission(publicPermission = true)
@GetMapping("/queryOrgOrderByOrgId")
public WeaResult<Object> queryOrgOrderByOrgId(HttpServletRequest request, HttpServletResponse response){
String orgIds = String.valueOf(request.getParameter("orgIds"));
log.error("orgIds:{}",orgIds);
List<Map<String, Object>> list = establishmentManagerService.queryOrgOrderByOrgId(orgIds);
return WeaResult.success(list);
}
}

View File

@ -1,6 +1,7 @@
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.seconddev.chapanda.hrm.constant.Constants;
@ -68,6 +69,39 @@ public class HrmCertificateFilesController {
}
@WeaPermission(publicPermission = true)
@PostMapping("/getincomepath2")
public WeaResult<Object> getIncomePath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("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);
// }
// }
try{
dataArray = JSONArray.parseArray(data);
}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
@ -99,6 +133,38 @@ public class HrmCertificateFilesController {
}
@WeaPermission(publicPermission = true)
@PostMapping("/getresignpath2")
public WeaResult<Object> getResignPath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("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);
// }
// }
try{
dataArray = JSONArray.parseArray(data);
}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
@ -129,6 +195,36 @@ public class HrmCertificateFilesController {
return WeaResult.success(dataMap);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getemploymentpath2")
public WeaResult<Object> getEmploymentPath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("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);
// }
// }
try{
dataArray = JSONArray.parseArray(data);
}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")
@ -155,6 +251,38 @@ public class HrmCertificateFilesController {
return WeaResult.success(dataMap);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getcontractpath2")
public WeaResult<Object> getContractPath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("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);
// }
// }
try{
dataArray = JSONArray.parseArray(data);
}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
@ -228,4 +356,109 @@ public class HrmCertificateFilesController {
return WeaResult.success(recordMap);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getcontractfile")
public WeaResult<Object> getContractFilePath(@RequestBody Map<String,Object> paramMap){
String data = String.valueOf(paramMap.get("data"));
log.error("data:{}",data);
JSONArray dataArray = new JSONArray();
if(StringUtils.isNotBlank(data)) {
try {
dataArray = JSONArray.parseArray(data);
} 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);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getcontractfile2")
public WeaResult<Object> getContractFilePath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("data"));
log.error("data:{}",data);
JSONArray dataArray = new JSONArray();
if(StringUtils.isNotBlank(data)) {
try {
dataArray = JSONArray.parseArray(data);
} 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);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getcontractfile3")
public WeaResult<Object> getContractFilePath3(@RequestParam("data") String data){
log.error("data:{}",data);
JSONArray dataArray = new JSONArray();
if(StringUtils.isNotBlank(data)) {
try {
dataArray = JSONArray.parseArray(data);
} 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);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getcontractfile4")
public WeaResult<Object> getContractFilePath4(@RequestBody Map<String,String> paramMap){
String data = String.valueOf(paramMap.get("data"));
log.error("data:{}",data);
JSONArray dataArray = new JSONArray();
if(StringUtils.isNotBlank(data)) {
try {
dataArray = JSONArray.parseArray(data);
} 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);
}
public static void main(String[] args) {
String data = "[{\"fileid\":\"1180268038345793538\"}]";
if(StringUtils.isNotBlank(data)) {
try {
JSONArray dataArray = JSONArray.parseArray(data);
System.out.println(dataArray);
} catch (Exception e) {
System.out.println( e);
}
}
}
}

View File

@ -8,6 +8,7 @@ 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;
@ -65,10 +66,117 @@ public class HrmInformationFilesController {
}
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);
}
@WeaPermission(publicPermission = true)
@PostMapping("/getinformationpath2")
public WeaResult<Object> getInformationPath2(@RequestBody JSONObject jsonObject){
String data = String.valueOf(jsonObject.getString("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);
// }
// }
try{
dataArray = JSONArray.parseArray(data);
}catch (Exception e){
log.error("{}",e);
}
}
log.error("dataArray:{}",dataArray.size());
String newZipFilePath = convertZipFile(dataArray, DownLoadTypeEnum.INFORMATION.getCode());
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+sdf.format(new Date());
String directoryPath = Constants.templatePath+ File.separator+downloadType+File.separator+sdf.format(new Date());
// 将字符串路径转换为Path对象
Path path = Paths.get(directoryPath);
// 检查目录是否存在
@ -81,10 +189,12 @@ public class HrmInformationFilesController {
}
String zipFilePath = directoryPath+File.separator+filename;
FileOutputStream fos = null;
ZipOutputStream zos = null;
try {
log.error("path:{}",zipFilePath);
FileOutputStream fos = new FileOutputStream(zipFilePath);
ZipOutputStream zos = new ZipOutputStream(fos);
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");
@ -96,19 +206,26 @@ public class HrmInformationFilesController {
log.error("jobNum:{}",jobNum);
if(StringUtils.isNotBlank(fileId)){
InputStream inputStream = null;
try {
FileData fileData = fileDownloadService.downloadFile(Long.parseLong(fileId));
FileObj fileObj = fileData.getFileObj();
// 获取文件的输入流
InputStream inputStream = fileData.getInputStream();
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();
}
}
}
}
@ -117,19 +234,28 @@ public class HrmInformationFilesController {
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();
}
Map<String,Object> dataMap = new HashMap<String,Object>();
dataMap.put("filepath",newZipFilePath);
return WeaResult.success(dataMap);
return newZipFilePath;
}
/***
* 电子签名模板预览接口
* @return
@ -139,127 +265,47 @@ public class HrmInformationFilesController {
@GetMapping("/downloadZip")
public ResponseEntity downloadZip(HttpServletRequest request) throws IOException{
String data = request.getParameter("data");
log.error("data:{}",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);
}
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 filename = sdf.format(new Date())+".zip";
return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
.body(fileBytes);
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"));
}
}
@RequestMapping("/downloadZip2")
public void downloadZip2(HttpServletRequest request,HttpServletResponse response) {
try {
String data = request.getParameter("data");
log.error("data:{}",data);
String zipFilePath = "";
if(StringUtils.isNotBlank(data)){
zipFilePath = hrmDownloadFilesService.convertBase64Data(data);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String filename = sdf.format(new Date())+".zip";
log.error("zipFilePath:{}",zipFilePath);
File file = ResourceUtils.getFile(zipFilePath);
byte[] fileBytes = Files.readAllBytes(file.toPath());
// 清空response
response.reset();
// 设置response的Header
response.setCharacterEncoding("UTF-8");
//Content-Disposition的作用告知浏览器以何种方式显示响应返回的文件用浏览器打开还是以附件的形式下载到本地保存
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
// filename表示文件的默认名称因为网络传输只支持URL编码的相关支付因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
// 告知浏览器文件的大小
response.addHeader("Content-Length", "" + fileBytes);
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
outputStream.write(fileBytes);
outputStream.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/***
* 电子签名模板预览接口
* @return
* @throws IOException
*/
@WeaPermission(publicPermission = true)
@GetMapping("/downloadFiles")
public ResponseEntity<byte[]> downloadFiles(HttpServletRequest request){
String data = request.getParameter("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());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
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);
}
}
}
}catch (IOException e){
log.error("e:{}",e);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String filename = sdf.format(new Date())+".zip";
return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
.body(baos.toByteArray());
}
// 将文件添加到zip输出流
private void addFileToZip(ZipOutputStream zos, byte[] fileData, String entryName,String jobNum,String fileName) throws IOException {
ZipEntry entry = new ZipEntry(fileName+"_"+jobNum+"/"+entryName);
@ -311,80 +357,4 @@ public class HrmInformationFilesController {
}
/**
* @param response
* @功能描述 下载文件:
*/
@RequestMapping("/downloadFiles2")
public void downloadFiles2(HttpServletRequest request,HttpServletResponse response) {
try {
String data = request.getParameter("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());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
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);
}
}
}
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String filename = sdf.format(new Date())+".zip";
// 清空response
response.reset();
// 设置response的Header
response.setCharacterEncoding("UTF-8");
//Content-Disposition的作用告知浏览器以何种方式显示响应返回的文件用浏览器打开还是以附件的形式下载到本地保存
//attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3"
// filename表示文件的默认名称因为网络传输只支持URL编码的相关支付因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
// 告知浏览器文件的大小
response.addHeader("Content-Length", "" + baos.size());
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
outputStream.write(baos.toByteArray());
outputStream.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,41 @@
package com.weaver.seconddev.chapanda.hrm.controller;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.seconddev.chapanda.hrm.service.WorkflowLeaveService;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@RestController
@RequestMapping("/api/secondev/chapanda/hrm/leave")
public class WorkflowLeaveController {
private final Logger log = LoggerFactory.getLogger(WorkflowLeaveController.class);
@Autowired
private WorkflowLeaveService workflowLeaveService;
@WeaPermission(publicPermission = true)
@GetMapping("/queryAttendanceTime")
public WeaResult<Object> queryAttendanceTime(HttpServletRequest request, HttpServletResponse response){
String employeeid = String.valueOf(request.getParameter("employeeid"));
log.error("employeeid:{}",employeeid);
String date = String.valueOf(request.getParameter("date"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if(StringUtils.isBlank(date)){
date = sdf.format(new Date());
}
log.error("date:{}",date);
Map<String,Object> dataMap = workflowLeaveService.queryAttendanceTime(employeeid,date);
return WeaResult.success(dataMap);
}
}

View File

@ -0,0 +1,147 @@
package com.weaver.seconddev.chapanda.hrm.dao;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
import com.weaver.seconddev.chapanda.hrm.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 EstablishmentManagerDao {
private final static Logger log = LoggerFactory.getLogger(EstablishmentManagerDao.class);
@Autowired
private DatabaseUtils databaseUtils;
/***
* @return
*/
public String quertEstId(String orgId,String planId,String year,String month){
String sourceType = "LOGIC";
String groupId = "weaver-hr-service";
String id = "";
try{
String dataSql =" select id from hr_est_cfg \n" +
" where org_id= ?\n" +
" and plan_id = ? \n" +
" and cfg_year = ? \n" +
" and cfg_month = ? " +
" and delete_type = 0 and tenant_key =?" ;
log.error("dataSql:" + dataSql);
List<String> paramList = new ArrayList<>(100);
paramList.add(orgId);
paramList.add(planId);
paramList.add(year);
paramList.add(month);
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 = recordList.get(0).get("id").toString();
}
}catch (Exception e){
e.printStackTrace();
log.error("queryTableFormId:e:" + e);
}
return id;
}
public String queryEstTotalByOrgId(String orgId,String planId,String year,String month){
String sourceType = "LOGIC";
String groupId = "weaver-hr-service";
String count = "0";
try{
String dataSql =" select ifnull(sum(est_count),0) as count \n" +
" from hr_est_cfg \n" +
" where tenant_key = ? \n" +
" and delete_type=0 \n" +
" and cfg_year = ? \n" +
" and cfg_month = ? \n" +
" and org_plan_status = 1 \n" +
" and org_id IN (\n" +
" select cid from eteams.depart_link \n" +
" where pid = ? \n" +
" and tenant_key = ? \n" +
" and delete_type=0 \n" +
")" ;
// String dataSql =" select ifnull(sum(est_count_with_sub),0) as count \n" +
// " from hr_est_cfg \n" +
// " where tenant_key = ? \n" +
// " and delete_type=0 \n" +
// " and cfg_year = ? \n" +
// " and cfg_month = ? \n" +
// " and org_plan_status = 1 \n" +
// " and org_id IN (\n" +
// " select id from " +
// " eteams.department \n" +
// " where parent = ? \n" +
// " and tenant_key = ? \n" +
// " and delete_type=0 \n" +
// ")" ;
log.error("dataSql:" + dataSql);
List<String> paramList = new ArrayList<>(100);
paramList.add(Constants.TENANT_KEY);
paramList.add(year);
paramList.add(month);
paramList.add(orgId);
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){
count = recordList.get(0).get("count").toString();
}
}catch (Exception e){
e.printStackTrace();
log.error("queryTableFormId:e:" + e);
}
return count;
}
public List<Map<String, Object>> queryEstTotalByOrgId(String orgIds){
String sourceType = "LOGIC";
String groupId = "weaver-hr-service";
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
try{
orgIds = "'"+orgIds.replace(",","','")+"'";
String dataSql =" select id,datarank,name \n" +
" from eteams.department\n" +
" where is_delete =0 \n" +
" and `type` ='department'\n" +
" and tenant_key= ?\n" +
" and id in("+orgIds+") \n" +
" order by datarank " ;
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){
e.printStackTrace();
log.error("queryTableFormId:e:" + e);
}
return recordList;
}
}

View File

@ -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("recordList:"+recordList.size());
if(recordList.size()>0){
recordMap = recordList.get(0);
}
}catch (Exception e){
e.printStackTrace();
log.error("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("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("recordList:"+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("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("recordList:"+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("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;
}
}

View File

@ -0,0 +1,85 @@
package com.weaver.seconddev.chapanda.hrm.dao;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.seconddev.chapanda.hrm.constant.Constants;
import com.weaver.seconddev.chapanda.hrm.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;
import java.util.stream.Collectors;
@Component
public class WorkflowLeaveDao {
private final static Logger log = LoggerFactory.getLogger(WorkflowLeaveDao.class);
@Autowired
private DatabaseUtils databaseUtils;
/***
* 获取eb表的appid和formid
* @param employeeid
* @param date
* @return
*/
public Map<String,Object> queryAttendanceTime(String employeeid,String date){
String sourceType = "LOGIC";
String groupId = "weaver-hr-service";
Map<String, Object> recordMap = new HashMap<String, Object>();
try{
String dataSql =" select s.period_range_start,s.period_range_end " +
" from attend_status_detail s \n" +
" where s.delete_type=0 \n" +
" and s.employee =? and s.attend_date =? " +
" and s.tenant_key =?" ;
log.error("dataSql:" + dataSql);
List<String> paramList = new ArrayList<>(100);
paramList.add(employeeid);
paramList.add(date);
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);
if(recordMap.containsKey("period_range_start")){
String period_range_start = String.valueOf(recordMap.get("period_range_start"));
if(StringUtils.isNotBlank(period_range_start) && period_range_start.length() == 19){
String period_date = period_range_start.substring(0,10);
String period_time = period_range_start.substring(11,19);
recordMap.put("start_date",period_date);
recordMap.put("start_time",period_time);
}
}
if(recordMap.containsKey("period_range_end")){
String period_range_end = String.valueOf(recordMap.get("period_range_end"));
if(StringUtils.isNotBlank(period_range_end) && period_range_end.length() == 19){
String period_date = period_range_end.substring(0,10);
String period_time = period_range_end.substring(11,19);
recordMap.put("end_date",period_date);
recordMap.put("end_time",period_time);
}
}
}
}catch (Exception e){
e.printStackTrace();
log.error("e:" + e);
}
return recordMap;
}
}

View File

@ -0,0 +1,17 @@
package com.weaver.seconddev.chapanda.hrm.service;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public interface EstablishmentManagerService {
String quertEstId(String orgId,String planId,String year,String month);
String queryEstTotalByOrgId(String orgId,String planId,String year,String month);
List<Map<String, Object>> queryOrgOrderByOrgId(String orgIds);
}

View File

@ -2,10 +2,7 @@ package com.weaver.seconddev.chapanda.hrm.service;
import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@Component
public interface HrmDownloadFilesService {
@ -17,4 +14,5 @@ public interface HrmDownloadFilesService {
String convertZipFile(JSONArray dataArray, String downloadType);
}

View File

@ -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);
}

View File

@ -0,0 +1,10 @@
package com.weaver.seconddev.chapanda.hrm.service;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public interface WorkflowLeaveService {
Map<String,Object>queryAttendanceTime(String employeeid,String date);
}

View File

@ -0,0 +1,41 @@
package com.weaver.seconddev.chapanda.hrm.service.impl;
import com.weaver.seconddev.chapanda.hrm.dao.EstablishmentManagerDao;
import com.weaver.seconddev.chapanda.hrm.service.EstablishmentManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/***
* author:shil
*/
@Service
public class EstablishmentManagerServiceImpl implements EstablishmentManagerService {
@Autowired
EstablishmentManagerDao establishmentManagerDao;
@Override
public String quertEstId(String orgId,String planId,String year,String month) {
String id = establishmentManagerDao.quertEstId(orgId,planId,year,month);
return id;
}
@Override
public String queryEstTotalByOrgId(String orgId,String planId,String year,String month) {
String count = establishmentManagerDao.queryEstTotalByOrgId(orgId,planId,year,month);
return count;
}
@Override
public List<Map<String, Object>> queryOrgOrderByOrgId(String orgIds) {
List<Map<String, Object>> list = establishmentManagerDao.queryEstTotalByOrgId(orgIds);
return list;
}
}

View File

@ -53,7 +53,7 @@ public class HrmDownloadFilesServiceImpl implements HrmDownloadFilesService {
}
log.error("byteStream:{}",byteStream.toByteArray().length);
}catch (IOException e) {
log.error("e:{}",e.getMessage());
log.error("io-e:{}",e.getMessage());
}
return byteStream.toByteArray();
}
@ -122,7 +122,7 @@ public class HrmDownloadFilesServiceImpl implements HrmDownloadFilesService {
inputStream.close();
} catch (IOException e) {
log.error("e:" , e);
log.error("io-e:" , e);
}finally {
if (inputStream != null) {
inputStream.close();

View File

@ -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;
}
}

View File

@ -0,0 +1,23 @@
package com.weaver.seconddev.chapanda.hrm.service.impl;
import com.weaver.seconddev.chapanda.hrm.dao.WorkflowLeaveDao;
import com.weaver.seconddev.chapanda.hrm.service.WorkflowLeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/***
* author:shil
*/
@Service
public class WorkflowLeaveServiceImpl implements WorkflowLeaveService {
@Autowired
WorkflowLeaveDao workflowLeaveDao;
@Override
public Map<String,Object> queryAttendanceTime(String employeeid, String date) {
Map<String,Object> dataList = workflowLeaveDao.queryAttendanceTime(employeeid,date);
return dataList;
}
}

View File

@ -0,0 +1,27 @@
package com.weaver.seconddev.chapanda.hrm.test;
import org.apache.commons.lang3.StringUtils;
/**
* packageName com.weaver.seconddev.chapanda.hrm.test
*
* @ClassName test99
* @Author shil
* @Date 2025/9/3 13:16
* @Description TODO
*/
public class test99 {
public static void main(String[] args) {
String period_range_start = "2025-09-03 15:00:00";
System.out.println(period_range_start.length());
if(StringUtils.isNotBlank(period_range_start) && period_range_start.length() == 19){
String period_date = period_range_start.substring(0,10);
System.out.println(period_date);
String period_time = period_range_start.substring(11,19);
System.out.println(period_time);
}
}
}

View File

@ -78,5 +78,6 @@ public class Constants {
public static String zpssyfzd = "extzhaoxushishiyuefen_431582_1686993167";
public static String jjcdzdm = "extzhaopinjinjidu_431582_1886847991";
public static String xbzdm = "extxingbieyaoqiu_431582_960838668";
}

View File

@ -0,0 +1,76 @@
package com.weaver.seconddev.chapanda.beisen.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;
}
@Override
public String toString() {
return "OkHttpDto{" +
"responseCode=" + responseCode +
", responseBody='" + responseBody + '\'' +
", dataCode=" + dataCode +
", dataMsg='" + dataMsg + '\'' +
", dataJson=" + dataJson +
'}';
}
}

View File

@ -13,6 +13,7 @@ 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.entity.OkHttpDto;
import com.weaver.seconddev.chapanda.beisen.util.*;
import com.weaver.teams.domain.department.SimpleDepartment;
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
@ -176,9 +177,22 @@ public class Esb2BeisenJobRequirementAction implements EsbServerlessRpcRemoteInt
String rzzg = String.valueOf(params.get("rzzg "));
String zxssyf = String.valueOf(params.get("zxssyf"));
String jjcd = String.valueOf(params.get("jjcd"));
int gzdd = Integer.valueOf(String.valueOf(params.get("gzdd")));
log.error("xqmc:" + xqmc);
log.error("orgId:" + orgId);
String dataId = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
log.error("gzdd:" + gzdd);
String xb_value = "";
String xbyq = String.valueOf(params.get("xbyq"));
if("1".equals(xbyq)){
xb_value = "male";
}else if("2".equals(xbyq)){
xb_value = "female";
}else if("3".equals(xbyq)){
xb_value = "no";
}
log.error("xb_value:" + xb_value);
OkHttpDto okHttpDto = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
requestname,beisenCreateUserId,
createDate,requirementCount,
arivalTime,
@ -191,9 +205,21 @@ public class Esb2BeisenJobRequirementAction implements EsbServerlessRpcRemoteInt
workExperience,
kind,
isSecrecy,
originalCode,nlyq,zpgw,zwmc,beisenDutyUserId,xqmc,gzzz,rzzg,zxssyf,jjcd);
originalCode,nlyq,zpgw,zwmc,beisenDutyUserId,xqmc,gzzz,rzzg,zxssyf,jjcd,gzdd,xb_value);
if(okHttpDto.getResponseCode() !=200){
return WeaResult.fail(500,"请求北森招聘需求接口异常");
}
if(okHttpDto.getDataCode() !=200){
return WeaResult.fail(500,"创建北森招聘需求接口异常,"+okHttpDto.getDataMsg());
}
String dataId = okHttpDto.getDataJson().getString("dataId");
if(StringUtils.isBlank(dataId)){
return WeaResult.fail(500,"创建北森招聘需求接口失败,"+okHttpDto.getDataMsg());
}
log.error("dataId:" + dataId);
// if(StringUtils.isNotBlank(dataId)){
// String sourceType = "";
// String groupId = "";

View File

@ -6,6 +6,7 @@ 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.entity.OkHttpDto;
import com.weaver.seconddev.chapanda.beisen.util.*;
import com.weaver.teams.domain.user.SimpleEmployee;
import org.apache.commons.lang3.StringUtils;
@ -166,7 +167,28 @@ public class Esb2BeisenJobRequirementCreateAction implements EsbServerlessRpcRem
log.error("rzzg:" + rzzg);
log.error("orgId:" + orgId);
String dataId = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
int gzdd = 0;
String gzddStr = String.valueOf(params.get("gzdd"));
log.error("gzddStr:" + gzddStr);
if(StringUtils.isNotBlank(gzddStr)){
gzdd = Integer.valueOf(String.valueOf(params.get("gzdd")));
}
// 性别要求extxingbieyaoqiu_431582_960838668
// 1 male
// 2 female
// 不限 3 no
String xb_value = "";
String xbyq = String.valueOf(params.get("xbyq"));
if("1".equals(xbyq)){
xb_value = "male";
}else if("2".equals(xbyq)){
xb_value = "female";
}else if("3".equals(xbyq)){
xb_value = "no";
}
OkHttpDto okHttpDto = jobRequirement2BeisenUtil.sendJobRequirement(requirementStatus,requirementType,
requestname,beisenCreateUserId,
createDate,requirementCount,
arivalTime,
@ -186,11 +208,25 @@ public class Esb2BeisenJobRequirementCreateAction implements EsbServerlessRpcRem
beisenDutyUserId,
xqmc,
gzzz,
rzzg,zxssyf,jjcd
rzzg,zxssyf,jjcd,gzdd,xb_value
);
log.error("dataId:" + dataId);
log.error("okHttpDto:" + okHttpDto.toString());
log.error("getDataCode:" + okHttpDto.getDataCode());
if(okHttpDto.getResponseCode() !=200){
return WeaResult.fail(500,"请求北森招聘需求接口异常");
}
if(okHttpDto.getDataCode() != 200){
return WeaResult.fail(500,"创建北森招聘需求接口异常,"+okHttpDto.getDataMsg());
}
String dataId = okHttpDto.getDataJson().getString("dataid");
if(StringUtils.isBlank(dataId)){
return WeaResult.fail(500,"创建北森招聘需求接口失败,"+okHttpDto.getDataMsg());
}
// if(StringUtils.isNotBlank(dataId)){
// String sourceType = "";
// String groupId = "";

View File

@ -0,0 +1,178 @@
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.OkHttpDto;
import com.weaver.seconddev.chapanda.beisen.util.BeisenQueryDeptIdUtil;
import com.weaver.seconddev.chapanda.beisen.util.BeisenQueryUseridUtil;
import com.weaver.seconddev.chapanda.beisen.util.JobRequirement2BeisenUtil;
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("Esb2BeisenJobRequirementUpdateAction")
public class Esb2BeisenJobRequirementUpdateAction implements EsbServerlessRpcRemoteInterface {
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenJobRequirementUpdateAction.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("Esb2BeisenJobRequirementUpdateAction start");
String form_data_id = (String) params.get("form_data_id");
String requirementId = (String) params.get("requirementId");
int requirementStatus = converInteger(params,"requirementStatus");
int requirementType = converInteger(params,"requirementType");
String xqmc = (String) params.get("xqmc");
String createDate = (String) params.get("createDate");
String arivalTime = (String) params.get("arivalTime");
String finishTime = String.valueOf(params.get("finishTime"));
log.error("requirementStatus:" + requirementStatus);
log.error("requirementType:" + requirementType);
log.error("requirementId:" + requirementId);
log.error("finishTime:" + finishTime);
String createBy = String.valueOf(params.get("createBy"));
String dutyUserId = String.valueOf(params.get("dutyUserId"));
String originalId = String.valueOf(params.get("originalId"));
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 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();
}
OkHttpDto okHttpDto = jobRequirement2BeisenUtil.updateJobRequirement(requirementStatus,requirementType,
createDate, arivalTime, finishTime, xqmc,
beisenCreateUserId,
createByEmail,
dutyUserEmail,
orgId,
originalCode,
beisenDutyUserId
);
log.error("okHttpDto:" + okHttpDto.toString());
log.error("getDataCode:" + okHttpDto.getDataCode());
if(okHttpDto.getResponseCode() !=200){
return WeaResult.fail(500,"调用北森招聘需求更新接口异常");
}
if(okHttpDto.getDataCode() != 200){
return WeaResult.fail(500,"北森招聘需求更新接口异常,"+okHttpDto.getDataMsg());
}
Map<String, Object> actionMap = new HashMap<String, Object>();
actionMap.put("code",200);
actionMap.put("msg","森招聘需求更新成功");
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;
}
}

View File

@ -2,6 +2,7 @@ package com.weaver.seconddev.chapanda.beisen.util;
import com.alibaba.fastjson.JSONObject;
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
import com.weaver.seconddev.chapanda.beisen.entity.OkHttpDto;
import okhttp3.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -18,7 +19,7 @@ public class JobRequirement2BeisenUtil {
@Autowired
Token2BeiSenUtil token2BeiSenUtil ;
public String sendJobRequirement(int requirementStatus,
public OkHttpDto sendJobRequirement(int requirementStatus,
int requirementType,
String requestname,
int beisenCreateBy,
@ -43,9 +44,9 @@ public class JobRequirement2BeisenUtil {
String gzzz,
String rzzg,
String zxssyf,
String jjcd
String jjcd, int gzdd,String xb_value
){
String data = "";
OkHttpDto okHttpDto = new OkHttpDto();
String token = token2BeiSenUtil.getToken();
if(StringUtils.isNotBlank(token)){
@ -175,16 +176,26 @@ public class JobRequirement2BeisenUtil {
if(kind > -1){
bodyJson.put("kind",kind);
}
JSONObject customProperties = new JSONObject();
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);
}
if(StringUtils.isNotBlank(zwmc)){
customProperties.put(Constants.zwzd,zwmc);
}
if(StringUtils.isNotBlank(zxssyf)){
customProperties.put(Constants.zpssyfzd,zxssyf);
}
if(StringUtils.isNotBlank(jjcd)){
customProperties.put(Constants.jjcdzdm,jjcd);
}
if(StringUtils.isNotBlank(xb_value)){
customProperties.put(Constants.xbzdm,xb_value);
}
bodyJson.put("customProperties",customProperties);
log.error("beisenDutyUserId:{}",beisenDutyUserId);
if(beisenDutyUserId>-1){
bodyJson.put("dutyUser",beisenDutyUserId);
@ -198,17 +209,18 @@ public class JobRequirement2BeisenUtil {
bodyJson.put("qualification",rzzg);
}
bodyJson.put("placeCoreHR",gzdd);
bodyJson.put("isSecrecy",isSecrecy);
log.error("bodyJson:{}",bodyJson.toJSONString());
data = doHttpPost(token,bodyJson.toJSONString());
okHttpDto = doHttpPostCreate(token,bodyJson.toJSONString());
}
return data;
return okHttpDto;
}
public String doHttpPost(String token,String bodyJson){
String data = "";
public OkHttpDto doHttpPostCreate(String token,String bodyJson){
OkHttpDto okHttpDto = new OkHttpDto();
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
@ -226,21 +238,224 @@ public class JobRequirement2BeisenUtil {
String bodyData = response.body().string();
log.error("code:{}",code);
log.error("bodyData:{}",bodyData);
okHttpDto.setResponseCode(code);
okHttpDto.setResponseBody(bodyData);
String dataCode = "0";
String data = "";
String message = "";
if(code == 200){
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("code")){
String dataCode = dataJson.getString("code");
dataCode = dataJson.getString("code");
if("200".equals(dataCode)){
data = dataJson.getString("data");
}else{
message = dataJson.getString("message");
}
}
}
}else{
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("message")){
message = dataJson.getString("message");
}
}
}
log.error("message:{}",message);
log.error("data:{}",data);
log.error("dataCode:{}",Integer.valueOf(dataCode));
okHttpDto.setDataCode(Integer.valueOf(dataCode));
okHttpDto.setDataMsg(message);
JSONObject dataJson = new JSONObject();
dataJson.put("dataid",data);
okHttpDto.setDataJson(dataJson);
} catch (IOException e) {
log.error("e:{}",e);
}
return data;
return okHttpDto;
}
public static void main(String[] args) {
int code = 200;
String data = "";
String message = "";
String bodyData = "{\"data\":\"00000000-0000-0000-0000-000000000000\",\"code\":400,\"message\":\"requirementType参数必填\\\\r\\\\n未找到Email为 liugangju@chabaidao.com 的员工\"}";
if(code == 200){
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("code")){
int dataCode = dataJson.getInteger("code");
if("200".equals(dataCode)){
data = dataJson.getString("data");
}else{
message = dataJson.getString("message");
}
}
}
}else{
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("message")){
message = dataJson.getString("message");
}
}
}
System.out.println(message);
System.out.println(data);
}
public OkHttpDto updateJobRequirement(int requirementStatus,
int requirementType,
String createDate,
String arivalTime,
String finishTime,
String xqmc,
int beisenCreateBy,
String createByEmail,
String dutyUserEmail,
int beisenDepartmentId,
String originalCode,
int beisenDutyUserId
){
OkHttpDto okHttpDto = new OkHttpDto();
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);
}
log.error("beisenCreateBy:{}",beisenCreateBy);
if(beisenCreateBy > -1){
bodyJson.put("createBy",beisenCreateBy);
}
bodyJson.put("dutyUserEmail",dutyUserEmail);
bodyJson.put("createByEmail",createByEmail);
bodyJson.put("name",xqmc);
if(beisenDepartmentId > -1){
bodyJson.put("departmentId",beisenDepartmentId);
}else{
if(StringUtils.isNotBlank(originalCode)){
bodyJson.put("orgCode",originalCode);
}
}
if(beisenDutyUserId>-1){
bodyJson.put("dutyUser",beisenDutyUserId);
}
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);
if(!finishTime.contains("T")){
finishTime = finishTime+"T00:00:00";
}
bodyJson.put("finishTime",finishTime);
log.error("bodyJson:{}",bodyJson.toJSONString());
okHttpDto = doHttpPostUpdate(token,bodyJson.toJSONString());
}
return okHttpDto;
}
public OkHttpDto doHttpPostUpdate(String token,String bodyJson){
OkHttpDto okHttpDto = new OkHttpDto();
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);
okHttpDto.setResponseCode(code);
okHttpDto.setResponseBody(bodyData);
String dataCode = "0";
String message = "";
if(code == 200){
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("code")){
dataCode = dataJson.getString("code");
if(!"200".equals(dataCode)){
message = dataJson.getString("message");
}
}
}
}else{
if(StringUtils.isNotBlank(bodyData)){
JSONObject dataJson = JSONObject.parseObject(bodyData);
if(dataJson.containsKey("message")){
message = dataJson.getString("message");
}
}
}
log.error("message:{}",message);
log.error("dataCode:{}",Integer.valueOf(dataCode));
okHttpDto.setDataCode(Integer.valueOf(dataCode));
okHttpDto.setDataMsg(message);
} catch (IOException e) {
log.error("e:{}",e);
}
return okHttpDto;
}
}

View File

@ -82,6 +82,9 @@ public class Esb2EsignCreateRequest4PartiesAction implements EsbServerlessRpcRem
accountIds = dataJson.getString("accountIds");
uniqueIds = dataJson.getString("uniqueIds");
fileKeys = dataJson.getString("fileKeys");
if(StringUtils.isBlank(signFlowId)){
return WeaResult.fail(500,"创建签署流程异常,"+okHttpDto.getDataMsg());
}
}else{
return WeaResult.fail(500,"创建签署流程异常,"+okHttpDto.getDataMsg());
}

View File

@ -8,7 +8,7 @@ public class Constants {
public static String feishuHost = "https://open.feishu.cn";
public static String tokenUrl = "/open-apis/auth/v3/tenant_access_token/internal";
public static String messageUrl = "/open-apis/im/v1/messages?receive_id_type=open_id";
public static String messageUrl = "/open-apis/im/v1/messages?receive_id_type=union_id";
public static String app_id = "cli_a8d0ee6b667dd00e";
public static String app_secret = "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0";
@ -23,12 +23,12 @@ public class Constants {
public static boolean excludeStatistics = false ;
public static String primaryUrl = "/open-apis/calendar/v4/calendars/primary?user_id_type=open_id";
public static String primaryUrl = "/open-apis/calendar/v4/calendars/primary?user_id_type=union_id";
public static String calendarEventsUrl ="/open-apis/calendar/v4/calendars/%s/events?idempotency_key=%s&user_id_type=open_id";
public static String calendarEventsUrl ="/open-apis/calendar/v4/calendars/%s/events?idempotency_key=%s&user_id_type=union_id";
public static String calendarAttendeesUrl = "/open-apis/calendar/v4/calendars/%s/events/%s/attendees?user_id_type=open_id";
public static String calendarAttendeesUrl = "/open-apis/calendar/v4/calendars/%s/events/%s/attendees?user_id_type=union_id";
public static int color = -1 ;
@ -45,14 +45,16 @@ public class Constants {
public static String openIdUrl = "/open-apis/contact/v3/users/batch_get_id?user_id_type=open_id";
public static String userIdUrl = "/open-apis/contact/v3/users/batch_get_id?user_id_type=user_id";
public static String unionIdUrl = "/open-apis/contact/v3/users/batch_get_id?user_id_type=union_id";
public static String workflowApproveUrl = "/open-apis/approval/v4/external_instances" ;
public static String HrmHost = "https://hrtest.chabaidao.com";
public static String updateMode = "UPDATE";
public static String createTimeoffUrl = "/open-apis/calendar/v4/timeoff_events?user_id_type=open_id";
public static String createTimeoffUrl = "/open-apis/calendar/v4/timeoff_events?user_id_type=union_id";
public static String timeZone = "Asia/Shanghai";
@ -62,7 +64,7 @@ public class Constants {
public static boolean cancelNeedNotification = false;
public static String updateCalendarUrl ="/open-apis/calendar/v4/calendars/%s/events/%s?user_id_type=open_id";
public static String updateCalendarUrl ="/open-apis/calendar/v4/calendars/%s/events/%s?user_id_type=union_id";
public static String sendBotUrl = "/open-apis/approval/v1/message/send";

View File

@ -43,10 +43,10 @@ public class QueryFeishuCardDataController {
// returnJson.put("challenge",challenge);
// AAqzTJll9BcFE
String event = "";
boolean isTrue = false;
if(params.containsKey("event")){
String event = params.get("event").toString();
event = params.get("event").toString();
log.error("event:{}",event);
if(StringUtils.isNotBlank(event)){
isTrue = convertData(event);
@ -56,26 +56,57 @@ public class QueryFeishuCardDataController {
JSONObject returnJson = new JSONObject();
log.error("isTrue:{}",isTrue);
if(isTrue){
JSONObject dataJson = new JSONObject();
dataJson.put("template_id","AAq9MOwxqoNUF");
JSONObject template_variable = new JSONObject();
template_variable.put("zzrs","2000");
template_variable.put("jdlzrs","20");
template_variable.put("jdrzrs","30");
template_variable.put("ycqrs","1900");
template_variable.put("qjrs","10");
template_variable.put("cdztrs","50");
template_variable.put("srtx","5");
template_variable.put("zztx","3");
template_variable.put("zntx","1");
dataJson.put("template_variable",template_variable);
JSONObject cardJson = new JSONObject();
cardJson.put("type","template");
cardJson.put("data",dataJson);
if(event.contains("scene-1,")){
JSONObject dataJson = new JSONObject();
dataJson.put("template_id","AAq9yHyFw3zOZ");
JSONObject template_variable = new JSONObject();
template_variable.put("ycq","21");
template_variable.put("sjcq","20");
template_variable.put("jdrzrs","30");
template_variable.put("qj","0.5");
template_variable.put("cc","10");
template_variable.put("jb","50");
template_variable.put("gc","2");
template_variable.put("yccq","1");
template_variable.put("bkcs","2");
template_variable.put("njye","8");
template_variable.put("txye","12");
template_variable.put("dxbjye","2");
dataJson.put("template_variable",template_variable);
JSONObject cardJson = new JSONObject();
cardJson.put("type","template");
cardJson.put("data",dataJson);
returnJson.put("card",cardJson);
log.error("returnJson:{}",returnJson.toJSONString());
}
if(event.contains("scene-5,")){
JSONObject dataJson = new JSONObject();
dataJson.put("template_id","AAq9MOwxqoNUF");
JSONObject template_variable = new JSONObject();
template_variable.put("zzrs","2000");
template_variable.put("jdlzrs","20");
template_variable.put("jdrzrs","30");
template_variable.put("ycqrs","1900");
template_variable.put("qjrs","10");
template_variable.put("cdztrs","50");
template_variable.put("srtx","5");
template_variable.put("zztx","3");
template_variable.put("zntx","1");
dataJson.put("template_variable",template_variable);
JSONObject cardJson = new JSONObject();
cardJson.put("type","template");
cardJson.put("data",dataJson);
returnJson.put("card",cardJson);
log.error("returnJson:{}",returnJson.toJSONString());
}
returnJson.put("card",cardJson);
log.error("returnJson:{}",returnJson.toJSONString());
}else{
JSONObject dataJson = new JSONObject();
dataJson.put("template_id","AAqzTJll9BcFE");

View File

@ -55,4 +55,70 @@ public class HrmQueryOpenIdDao {
return openId;
}
public String queryFeishuUserId(String employeeId){
String groupId = "weaver-workflow-report-serviceworkflowreport";
String sourceType = "LOGIC";
String userId = "";
try{
String dataSql =" select u.user_id\n" +
" from eb_hrm_user u\n" +
" inner join eteams.employee e on e.mobile = u.mobile \n" +
" where e.delete_type = 0\n" +
" and u.delete_type = 0\n" +
" and e.id =? and u.tenant_key = ? and e.tenant_key = ? " ;
log.error("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("recordList:{}",recordList.size());
if(recordList.size() > 0){
userId = String.valueOf(recordList.get(0).get("user_id"));
}
}catch (Exception e){
e.printStackTrace();
log.error("e:" + e);
}
return userId;
}
public String queryFeishuUnionId(String employeeId){
String groupId = "weaver-workflow-report-serviceworkflowreport";
String sourceType = "LOGIC";
String userId = "";
try{
String dataSql =" select u.union_id\n" +
" from eb_hrm_user u\n" +
" inner join eteams.employee e on e.mobile = u.mobile \n" +
" where e.delete_type = 0\n" +
" and u.delete_type = 0\n" +
" and e.id =? and u.tenant_key = ? and e.tenant_key = ? " ;
log.error("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("recordList:{}",recordList.size());
if(recordList.size() > 0){
userId = String.valueOf(recordList.get(0).get("union_id"));
}
}catch (Exception e){
e.printStackTrace();
log.error("e:" + e);
}
return userId;
}
}

View File

@ -0,0 +1,65 @@
package com.weaver.seconddev.chapanda.feishu.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;
}
}

View File

@ -88,17 +88,21 @@ public class Esb2FeishuBotCreateTodoAction implements EsbServerlessRpcRemoteInte
log.error("operator_open_id:{}",operator_open_id);
log.error("create_open_id:{}",create_open_id);
log.error("send_open_id:{}",send_open_id);
if(StringUtils.isNotBlank(create_open_id)){
if(StringUtils.isNotBlank(send_open_id)){
message_ids = esb2FeishuBotCreateTodoUtil.senBotTodoMessage(
requestid,requestName,requestmark,
create_open_id,send_open_id,operator_open_id,
mobileurl,pcurl
);
if(StringUtils.isNotBlank(operator_open_id)){
message_ids = esb2FeishuBotCreateTodoUtil.senBotTodoMessage(
requestid,requestName,requestmark,
create_open_id,send_open_id,operator_open_id,
mobileurl,pcurl
);
}else{
log.error("send_open_id:{}","获取操作人员openid为空");
}
}else{
log.error("send_open_id:{}","获取待办人员为空");
log.error("send_open_id:{}","获取待办人员openid为空");
}
}else{
log.error("creatorMobile:{}","创建人飞书openid为空");

View File

@ -2,6 +2,7 @@ package com.weaver.seconddev.chapanda.feishu.esb;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.chapanda.feishu.entity.OkHttpDto;
import com.weaver.seconddev.chapanda.feishu.util.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -41,9 +42,17 @@ public class Esb2FeishuCalendarsCancelAction implements EsbServerlessRpcRemoteIn
return WeaResult.fail(500,"获取飞书的日程信息失败");
}
String code = "";
int code = -1;
int responseCode = 0;
String msg = "";
if(StringUtils.isNotBlank(calendar_id) && StringUtils.isNotBlank(event_id)){
code = esb2FeishuCancelCalendarUtil.cancelCalendarEvents(calendar_id,event_id);
OkHttpDto okHttpDto = esb2FeishuCancelCalendarUtil.cancelCalendarEvents(calendar_id,event_id);
responseCode = okHttpDto.getResponseCode();
code = okHttpDto.getDataCode();
msg = okHttpDto.getDataMsg();
}
if(responseCode != 200){
return WeaResult.fail(500,"飞书日程取消请求异常,"+msg);
}
log.error("code:{}",code);
if(!"0".equals(code)){

View File

@ -2,13 +2,11 @@ package com.weaver.seconddev.chapanda.feishu.esb;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.hrm.util.HrmCommonUtil;
import com.weaver.ebuilder.form.client.entity.obj.Obj;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuCalendarAttendeesUtil;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuCalendarEventsUtil;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuCalendarPrimaryUtil;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
import com.weaver.teams.domain.user.SimpleEmployee;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -79,8 +77,7 @@ public class Esb2FeishuCalendarsEventsAction implements EsbServerlessRpcRemoteIn
// if(StringUtils.isBlank(mobile)){
// return WeaResult.fail(500,"获取手机号为空");
// }
String openId = esb2FeishuOpenIdUtil.queryFeishuOpenId(employee_id);
String unionId = esb2FeishuOpenIdUtil.queryFeishuUnionId(employee_id);
// if(StringUtils.isNotBlank(mobile)){
// Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(mobile);
// if(userMap.containsKey(mobile)){
@ -88,12 +85,12 @@ public class Esb2FeishuCalendarsEventsAction implements EsbServerlessRpcRemoteIn
// }
// }
if(StringUtils.isBlank(openId)){
if(StringUtils.isBlank(unionId)){
return WeaResult.fail(500,"获取飞书的人员信息失败");
}
log.error("Esb2FeishuCalendarsEventsAction start");
log.error("openId:{}",openId);
log.error("unionId:{}",unionId);
String attendee_id = "";
String calendarId = esb2FeishuCalendarPrimaryUtil.queryUserCalendarPrimary();
@ -112,7 +109,7 @@ public class Esb2FeishuCalendarsEventsAction implements EsbServerlessRpcRemoteIn
}
if(StringUtils.isNotBlank(event_id)){
attendee_id = esb2FeishuCalendarAttendeesUtil.sendUserCalendarEvents(openId,calendarId,event_id);
attendee_id = esb2FeishuCalendarAttendeesUtil.sendUserCalendarEvents(unionId,calendarId,event_id);
}
if(StringUtils.isBlank(attendee_id)){
@ -126,7 +123,7 @@ public class Esb2FeishuCalendarsEventsAction implements EsbServerlessRpcRemoteIn
actionMap.put("attendeeId",attendee_id);
actionMap.put("calendarId",calendarId);
actionMap.put("event_id",event_id);
actionMap.put("openId",openId);
actionMap.put("openId",unionId);
actionMap.put("dataid",dataid);
return WeaResult.success(actionMap);
}

View File

@ -56,7 +56,9 @@ public class Esb2FeishuCreateCalendarsTimeoffAction implements EsbServerlessRpcR
// return WeaResult.fail(500,"获取手机号为空");
// }
String openId = esb2FeishuOpenIdUtil.queryFeishuOpenId(employee_id);
// String openId = esb2FeishuOpenIdUtil.queryFeishuOpenId(employee_id);
String unionId = esb2FeishuOpenIdUtil.queryFeishuUnionId(employee_id);
// if(StringUtils.isNotBlank(mobile)){
// Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(mobile);
// if(userMap.containsKey(mobile)){
@ -64,13 +66,13 @@ public class Esb2FeishuCreateCalendarsTimeoffAction implements EsbServerlessRpcR
// }
// }
if(StringUtils.isBlank(openId)){
if(StringUtils.isBlank(unionId)){
return WeaResult.fail(500,"获取飞书的人员信息失败");
}
String timeoff_event_id = "";
if(StringUtils.isNotBlank(openId)){
timeoff_event_id = esb2FeishuCreateCalendarTimeoffUtil.createCalendarTimeOff(openId,title,description,start_date,end_date,type);
if(StringUtils.isNotBlank(unionId)){
timeoff_event_id = esb2FeishuCreateCalendarTimeoffUtil.createCalendarTimeOff(unionId,title,description,start_date,end_date,type);
}
log.error("timeoff_event_id:{}",timeoff_event_id);
@ -82,7 +84,7 @@ public class Esb2FeishuCreateCalendarsTimeoffAction implements EsbServerlessRpcR
actionMap.put("code",200);
actionMap.put("msg","成功");
actionMap.put("timeoffEventId",timeoff_event_id);
actionMap.put("openId",openId);
actionMap.put("openId",unionId);
actionMap.put("dataid",dataid);
return WeaResult.success(actionMap);
}

View File

@ -53,12 +53,15 @@ public class Esb2FeishuSendMessageCardAction implements EsbServerlessRpcRemoteIn
return WeaResult.fail(500,"1. is null");
}
String openId = esb2FeishuOpenIdUtil.queryFeishuOpenId(receiveId);
if(StringUtils.isBlank(openId)){
// String openId = esb2FeishuOpenIdUtil.queryFeishuOpenId(receiveId);
String unionId = esb2FeishuOpenIdUtil.queryFeishuUnionId(receiveId);
if(StringUtils.isBlank(unionId)){
return WeaResult.fail(500,"openId is null");
}
Map<String, Object> dataMap = esb2FeishuSendMessageUtil.senCardMessage(templateId,templateVersionName,openId,params);
Map<String, Object> dataMap = esb2FeishuSendMessageUtil.senCardMessage(templateId,templateVersionName,unionId,params);
String chat_id = (String) dataMap.get("chat_id");
String message_id = (String) dataMap.get("message_id");

View File

@ -4,6 +4,7 @@ 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.feishu.dao.HrmQueryOpenIdDao;
import com.weaver.seconddev.chapanda.feishu.entity.OkHttpDto;
import com.weaver.seconddev.chapanda.feishu.util.CommonUtil;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendTodoUtil;
@ -57,9 +58,7 @@ public class Esb2FeishuSendTodoAction implements EsbServerlessRpcRemoteInterface
String nodeName = String.valueOf(params.get("nodeName"));
String degree = String.valueOf(params.get("degree"));
log.error("requestid:{}",requestid);
log.error("requestName:{}",requestName);
log.error("nodeName:{}",nodeName);
String operatorid = String.valueOf(params.get("operatorid"));
String mobileurl = String.valueOf(params.get("mobileurl"));
@ -83,46 +82,38 @@ public class Esb2FeishuSendTodoAction implements EsbServerlessRpcRemoteInterface
}
}
log.error("msgType:{}",msgType);
log.error("operatorid:{}",operatorid);
// log.error("requestid:{}",requestid);
// log.error("requestName:{}",requestName);
// log.error("nodeName:{}",nodeName);
// log.error("msgType:{}",msgType);
// log.error("operatorid:{}",operatorid);
// log.error("approvestatus:{}",approvestatus);
String cid = String.valueOf(params.get("cid"));
log.error("bot:requestid:{},nodeid:{},operatorid:{},cid{},msgType:{},todo",requestid,nodeId,operatorid,cid,msgType);
log.error("todo:requestid:{},nodeid:{},operatorid:{},cid{},msgType:{},approvestatus:{}",requestid,nodeId,operatorid,cid,msgType,approvestatus);
String code = "";
if("0".equals(msgType)){
String create_open_id = esb2FeishuOpenIdUtil.queryFeishuOpenId(creatorid);
String creatorname = "";
String create_open_id = "";
if(StringUtils.isNotBlank(creatorid)){
Long creator_id = commonUtil.convertStringToLong(creatorid);
if(creator_id > 0L){
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
String creatorMobile = creatorEmployee.getMobile();
log.error("creatorMobile:{}",creatorMobile);
creatorname = creatorEmployee.getUsername();
create_open_id = hrmQueryOpenIdDao.queryHrmOpenId(creatorid);
log.error("create_open_id:{}",create_open_id);
if(StringUtils.isBlank(create_open_id)){
if(StringUtils.isNotBlank(creatorMobile)) {
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
create_open_id = String.valueOf(userMap.get(creatorMobile));
}
}
}
}
// if(StringUtils.isNotBlank(creatorMobile)){
// Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
// create_open_id = String.valueOf(userMap.get(creatorMobile));
// }
log.error("create_open_id2:{}",create_open_id);
log.error("creatorname:{}",creatorname);
// log.error("create_open_id2:{}",create_open_id);
// log.error("creatorname:{}",creatorname);
String operator_open_id = esb2FeishuOpenIdUtil.queryFeishuOpenId(operatorid);
// if(StringUtils.isNotBlank(operatorid)){
// Long userid = Long.valueOf(operatorid);
// SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
@ -134,14 +125,13 @@ public class Esb2FeishuSendTodoAction implements EsbServerlessRpcRemoteInterface
// }
// }
log.error("create_open_id:{}",create_open_id);
log.error("operator_open_id:{}",operator_open_id);
// log.error("creatorMobile:{}",creatorMobile);
if(StringUtils.isNotBlank(create_open_id)){
if(StringUtils.isNotBlank(operator_open_id)){
String status = "PENDING";
code = esb2FeishuSendTodoUtil.senTodoMessage(
OkHttpDto okHttpDto = esb2FeishuSendTodoUtil.senTodoMessage(
requestid,requestName,requestmark,
creatorname,createTime,
nodeId,nodeName,
@ -149,14 +139,20 @@ public class Esb2FeishuSendTodoAction implements EsbServerlessRpcRemoteInterface
degree,mobileurl,pcurl,create_open_id,operator_open_id,
recepttime,status,cid
);
if(!"0".equals(code)){
log.error("operator_open_id:{}","创建飞书待办异常");
int responseCode = okHttpDto.getResponseCode();
if(responseCode == 200){
int dataCode = okHttpDto.getDataCode();
if(dataCode != 0){
log.error("创建飞书待办异常");
}
}else{
log.error("调用飞书待办接口异常");
}
}else{
log.error("todoOpenIdList:{}","获取待办人员为空");
log.error("待办人员飞书openid为空");
}
}else{
log.error("creatorMobile:{}","创建人飞书openid为空");
log.error("创建人飞书openid为空");
}
}

View File

@ -109,9 +109,9 @@ public class Esb2FeishuBotCreateTodoUtil {
summariesObject.put("summary","@i18n@summary");
summariesArray.add(summariesObject);
summariesObject = new JSONObject();
summariesObject.put("summary","@i18n@requestid");
summariesArray.add(summariesObject);
// summariesObject = new JSONObject();
// summariesObject.put("summary","@i18n@requestid");
// summariesArray.add(summariesObject);
JSONObject contentJson = new JSONObject();
contentJson.put("user_id",create_open_id);
@ -131,7 +131,7 @@ public class Esb2FeishuBotCreateTodoUtil {
JSONObject i18nResourcesTextsJson = new JSONObject();
i18nResourcesTextsJson.put("@i18n@title",requestName);
i18nResourcesTextsJson.put("@i18n@summary",requestName);
i18nResourcesTextsJson.put("@i18n@requestid",requestid);
// i18nResourcesTextsJson.put("@i18n@requestid",requestid);
JSONObject i18nResourcesJson = new JSONObject();
i18nResourcesJson.put("locale","zh-CN");
i18nResourcesJson.put("texts",i18nResourcesTextsJson);

View File

@ -2,6 +2,7 @@ package com.weaver.seconddev.chapanda.feishu.util;
import com.alibaba.fastjson.JSONObject;
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
import com.weaver.seconddev.chapanda.feishu.entity.OkHttpDto;
import okhttp3.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -18,30 +19,29 @@ public class Esb2FeishuCancelCalendarUtil {
@Autowired
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
public String cancelCalendarEvents(String calendar_id,String event_id) {
log.error("Esb2FeishuGetCalendarPrimaryUtil start");
String code = "";
public OkHttpDto cancelCalendarEvents(String calendar_id,String event_id) {
OkHttpDto okHttpDto = new OkHttpDto();
String token = esb2FeishuTokenUtil.getToken();
log.error("token:"+token);
if(StringUtils.isNotBlank(token)){
boolean needNotification = Constants.cancelNeedNotification;
String cancelCalendarUrl = String.format(Constants.cancelCalendarUrl, calendar_id,event_id) +"?need_notification="+needNotification;
log.error("cancelCalendarUrl:{}",cancelCalendarUrl);
okHttpDto = doHttpPost(token,cancelCalendarUrl);
String message = doHttpPost(token,cancelCalendarUrl);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
code = returnData.getString("code");
}
}
// if(StringUtils.isNotBlank(message)){
// JSONObject returnData = JSONObject.parseObject(message);
// if(returnData.containsKey("code")){
// code = returnData.getString("code");
// }
// }
}
return code;
return okHttpDto;
}
public String doHttpPost(String token,String cancelCalendarUrl){
public OkHttpDto doHttpPost(String token,String cancelCalendarUrl){
String msg = "";
OkHttpDto okHttpDto = new OkHttpDto();
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
@ -56,12 +56,33 @@ public class Esb2FeishuCancelCalendarUtil {
Response response = client.newCall(request).execute();
int code = response.code();
log.error("code:{}",code);
msg = response.body().string();
log.error("msg:"+msg);
String reposponseBody = response.body().string();
log.error("reposponseBody:"+reposponseBody);
okHttpDto.setResponseCode(code);
okHttpDto.setResponseBody(reposponseBody);
convertData(reposponseBody,okHttpDto);
} catch (IOException e) {
log.error("e:"+e);
throw new RuntimeException(e);
}
return msg;
return okHttpDto;
}
public void convertData(String message, OkHttpDto okHttpDto){
int code = -1;
String msg = "";
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
code = returnData.getInteger("code");
}
if(returnData.containsKey("msg")){
msg = returnData.getString("msg");
}
}
okHttpDto.setDataCode(code);
okHttpDto.setDataMsg(msg);
}
}

View File

@ -21,7 +21,7 @@ public class Esb2FeishuCreateCalendarTimeoffUtil {
@Autowired
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
public String createCalendarTimeOff(String user_open_id,String summary,String description,
public String createCalendarTimeOff(String user_union_id,String summary,String description,
String start_date,String end_date,String type) {
String timeoff_event_id = "";
@ -31,7 +31,7 @@ public class Esb2FeishuCreateCalendarTimeoffUtil {
if(StringUtils.isNotBlank(token)){
JSONObject bodyJson = new JSONObject();
bodyJson.put("user_id",user_open_id);
bodyJson.put("user_id",user_union_id);
bodyJson.put("title",summary);
bodyJson.put("description",description);
bodyJson.put("timezone",Constants.timeZone);

View File

@ -37,30 +37,28 @@ public class Esb2FeishuOpenIdUtil {
@Autowired
private HrmCommonUtil hrmCommonUtil;
public String queryFeishuOpenId(String employeeid) {
log.error("employeeid:{}",employeeid);
String openId = "";
try {
if(StringUtils.isNotBlank(employeeid)){
openId = hrmQueryOpenIdDao.queryHrmOpenId(employeeid);
log.error("openId1:{}",openId);
if(StringUtils.isBlank(openId)){
// openId = hrmQueryOpenIdDao.queryHrmOpenId(employeeid);
// log.error("openId1:{}",openId);
// if(StringUtils.isBlank(openId)){
Long employeeId = commonUtil.convertStringToLong(employeeid);
if(employeeId > 0L){
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
String creatorMobile = creatorEmployee.getMobile();
if(StringUtils.isNotBlank(creatorMobile)) {
Map<String, Object> creatorMap = queryFeishuOpenIdByMobiles(creatorMobile);
openId = String.valueOf(creatorMap.get(creatorMobile));
log.error("openId2:{}",openId);
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
String userMobile = userEmployee.getMobile();
log.error("userMobile:{}",userMobile);
if(StringUtils.isNotBlank(userMobile)) {
Map<String, Object> creatorMap = queryFeishuOpenIdByMobiles(userMobile);
openId = String.valueOf(creatorMap.get(userMobile));
}
}
}
// }
}
}catch (Exception e){
log.error("e:{}",e);
}
return openId;
}
@ -71,7 +69,7 @@ public class Esb2FeishuOpenIdUtil {
if(StringUtils.isNotBlank(token)){
List<String> mobiles = new ArrayList<String>();
mobiles.add(mobile);
String message = doHttpPost(mobiles,searchType,token);
String message = doHttpPost4FeishuOpenId(mobiles,searchType,token);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
@ -112,7 +110,7 @@ public class Esb2FeishuOpenIdUtil {
if(StringUtils.isNotBlank(token)){
List<String> emails = new ArrayList<String>();
emails.add(email);
String message = doHttpPost(emails,searchType,token);
String message = doHttpPost4FeishuOpenId(emails,searchType,token);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
@ -135,7 +133,7 @@ public class Esb2FeishuOpenIdUtil {
}
public String doHttpPost(List<String> dataList, String searchType, String token){
private String doHttpPost4FeishuOpenId(List<String> dataList, String searchType, String token){
String msg = "";
OkHttpClient client = new OkHttpClient().newBuilder()
@ -168,4 +166,196 @@ public class Esb2FeishuOpenIdUtil {
return msg;
}
public String queryFeishuUserId(String employeeid) {
log.error("employeeid:{}",employeeid);
String userId = "";
try {
if(StringUtils.isNotBlank(employeeid)){
userId = hrmQueryOpenIdDao.queryFeishuUserId(employeeid);
log.error("userId:{}",userId);
if(StringUtils.isBlank(userId)){
Long employeeId = commonUtil.convertStringToLong(employeeid);
if(employeeId > 0L){
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
String creatorMobile = creatorEmployee.getMobile();
if(StringUtils.isNotBlank(creatorMobile)) {
Map<String, Object> creatorMap = queryFeishuUserIdByMobiles(creatorMobile);
userId = String.valueOf(creatorMap.get(creatorMobile));
log.error("userId2:{}",userId);
}
}
}
}
}catch (Exception e){
log.error("e:{}",e);
}
return userId;
}
public Map<String, Object> queryFeishuUserIdByMobiles(String mobile) {
Map<String, Object> userMap = new HashMap<String, Object>();
String searchType = "mobiles";
String token = esb2FeishuTokenUtil.getToken();
if(StringUtils.isNotBlank(token)){
List<String> mobiles = new ArrayList<String>();
mobiles.add(mobile);
String message = doHttpPost4FeishuUserId(mobiles,searchType,token);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
String code = returnData.getString("code");
if("0".equals(code)){
JSONObject dataJson = returnData.getJSONObject("data");
JSONArray userList = dataJson.getJSONArray("user_list");
for(int i=0;i<userList.size();i++){
JSONObject userJson = userList.getJSONObject(i);
String user_id = "";
if(userJson.containsKey("user_id")){
user_id = userJson.getString("user_id");
}
userMap.put(mobile,user_id);
}
}
}
}
}
return userMap;
}
private String doHttpPost4FeishuUserId(List<String> dataList, String searchType, String token){
String msg = "";
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
String[] dataArray = new String[dataList.size()];
for(int i=0;i<dataList.size();i++){
dataArray[i] = dataList.get(i);
}
JSONObject bodyData = new JSONObject();
bodyData.put(searchType,dataArray);
RequestBody body = RequestBody.create(mediaType, bodyData.toJSONString());
try {
Request request = new Request.Builder()
.url(Constants.feishuHost+Constants.userIdUrl)
.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);
msg = response.body().string();
log.error("msg:"+msg);
} catch (IOException e) {
log.error("e:"+e);
throw new RuntimeException(e);
}
return msg;
}
public String queryFeishuUnionId(String employeeid) {
log.error("employeeid:{}",employeeid);
String unionId = "";
try {
if(StringUtils.isNotBlank(employeeid)){
unionId = hrmQueryOpenIdDao.queryFeishuUnionId(employeeid);
log.error("unionId:{}",unionId);
if(StringUtils.isBlank(unionId)){
Long employeeId = commonUtil.convertStringToLong(employeeid);
if(employeeId > 0L){
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
String creatorMobile = creatorEmployee.getMobile();
if(StringUtils.isNotBlank(creatorMobile)) {
Map<String, Object> creatorMap = queryFeishuUnionIdByMobiles(creatorMobile);
unionId = String.valueOf(creatorMap.get(creatorMobile));
log.error("unionId2:{}",unionId);
}
}
}
}
}catch (Exception e){
log.error("e:{}",e);
}
return unionId;
}
/***
*
* @param mobile
* @return
*/
public Map<String, Object> queryFeishuUnionIdByMobiles(String mobile) {
Map<String, Object> userMap = new HashMap<String, Object>();
String searchType = "mobiles";
String token = esb2FeishuTokenUtil.getToken();
if(StringUtils.isNotBlank(token)){
List<String> mobiles = new ArrayList<String>();
mobiles.add(mobile);
String message = doHttpPost4FeishuUnionId(mobiles,searchType,token);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
String code = returnData.getString("code");
if("0".equals(code)){
JSONObject dataJson = returnData.getJSONObject("data");
JSONArray userList = dataJson.getJSONArray("user_list");
for(int i=0;i<userList.size();i++){
JSONObject userJson = userList.getJSONObject(i);
String user_id = "";
if(userJson.containsKey("user_id")){
user_id = userJson.getString("user_id");
}
userMap.put(mobile,user_id);
}
}
}
}
}
return userMap;
}
private String doHttpPost4FeishuUnionId(List<String> dataList, String searchType, String token){
String msg = "";
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
String[] dataArray = new String[dataList.size()];
for(int i=0;i<dataList.size();i++){
dataArray[i] = dataList.get(i);
}
JSONObject bodyData = new JSONObject();
bodyData.put(searchType,dataArray);
RequestBody body = RequestBody.create(mediaType, bodyData.toJSONString());
try {
Request request = new Request.Builder()
.url(Constants.feishuHost+Constants.unionIdUrl)
.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);
msg = response.body().string();
log.error("msg:"+msg);
} catch (IOException e) {
log.error("e:"+e);
throw new RuntimeException(e);
}
return msg;
}
}

View File

@ -20,7 +20,7 @@ public class Esb2FeishuSendMessageUtil{
@Autowired
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
public Map<String, Object> senCardMessage(String template_id,String template_version_name,String openId, Map<String,Object> paraMap) {
public Map<String, Object> senCardMessage(String template_id,String template_version_name,String unionId, Map<String,Object> paraMap) {
Map<String, Object> messageMap = new HashMap<String, Object>();
@ -52,7 +52,7 @@ public class Esb2FeishuSendMessageUtil{
JSONObject data_Json = new JSONObject();
data_Json.put("template_id",template_id);
data_Json.put("template_version_name",template_version_name);
// data_Json.put("template_version_name",template_version_name);
data_Json.put("template_variable",templateVariable);
JSONObject contentJson = new JSONObject();
@ -60,7 +60,7 @@ public class Esb2FeishuSendMessageUtil{
contentJson.put("data",data_Json);
JSONObject bodyJson = new JSONObject();
bodyJson.put("receive_id",openId);
bodyJson.put("receive_id",unionId);
bodyJson.put("msg_type","interactive");
bodyJson.put("content", contentJson.toJSONString());
String uuid = UUID.randomUUID().toString();

View File

@ -4,6 +4,7 @@ import cn.hutool.json.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
import com.weaver.seconddev.chapanda.feishu.dao.WorkflowDegreeLevelDao;
import com.weaver.seconddev.chapanda.feishu.entity.OkHttpDto;
import okhttp3.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -26,13 +27,15 @@ public class Esb2FeishuSendTodoUtil {
@Autowired
private WorkflowDegreeLevelDao workflowDegreeLevelDao;
public String senTodoMessage(String requestid,String requestName,String requestmark,
public OkHttpDto senTodoMessage(String requestid,String requestName,String requestmark,
String creatorName, String createTime,
String nodeId, String nodeName, String archivingTime,
String degree,String mobileurl,String pcurl,
String create_open_id,String operator_open_id,
String recepttime,String status,String cid
) {
OkHttpDto okHttpDto = new OkHttpDto();
String code = "";
String token = esb2FeishuTokenUtil.getToken();
log.error("token:"+token);
@ -74,14 +77,14 @@ public class Esb2FeishuSendTodoUtil {
formList.add(formMap);
}
if(StringUtils.isNotBlank(requestid)){
Map<String, Object> formMap = new HashMap<String,Object>();
formMap.put("name","流程ID");
formMap.put("value",requestid);
formList.add(formMap);
}
// if(StringUtils.isNotBlank(requestid)){
// Map<String, Object> formMap = new HashMap<String,Object>();
// formMap.put("name","流程ID");
// formMap.put("value",requestid);
// formList.add(formMap);
// }
if(StringUtils.isNotBlank(requestid)){
if(StringUtils.isNotBlank(recepttime)){
Map<String, Object> formMap = new HashMap<String,Object>();
formMap.put("name","接收时间");
formMap.put("value",recepttime);
@ -95,7 +98,6 @@ public class Esb2FeishuSendTodoUtil {
formList.add(formMap);
}
if(StringUtils.isNotBlank(create_open_id)){
String bodyData = appendBodyParam(requestid,requestName,create_open_id,
department_id,department_name,
@ -105,22 +107,21 @@ public class Esb2FeishuSendTodoUtil {
log.error("feishu-todo:{}",bodyData);
String message = doPostSendMessage(bodyData,token);
if(StringUtils.isNotBlank(message)){
JSONObject returnData = JSONObject.parseObject(message);
if(returnData.containsKey("code")){
code = returnData.getString("code");
}
}
okHttpDto = doPostSendMessage(bodyData,token);
// if(StringUtils.isNotBlank(message)){
// JSONObject returnData = JSONObject.parseObject(message);
// if(returnData.containsKey("code")){
// code = returnData.getString("code");
// }
// }
}
}
return code;
return okHttpDto;
}
public String doPostSendMessage(String bodyData,
String token){
String msg = "";
public OkHttpDto doPostSendMessage(String bodyData, String token){
OkHttpDto okHttpDto = new OkHttpDto();
// "{\n \"approval_code\": \"5DB33242-4B8B-4D72-A64E-DF030E9D94EA\",\n \"status\": \"PENDING\",\n \"extra\": \"{\\\"测试\\\":\\\"泛微\\\"}\",\n \"instance_id\": \"t024j0gfn0\",\n \"links\": {\n \"pc_link\": \"http://10.60.4.124:30609/sp/workflow/flowpage/view/1154324404224876544\",\n \"mobile_link\": \"http://10.60.4.124:30609/sp/workflow/flowpage/view/1154324404224876544\"\n },\n \"title\": \"@i18n@1\",\n \"form\": [\n {\n \"name\": \"@i18n@2\",\n \"value\": \"@i18n@3\"\n }\n ],\n \"user_id\": \"ggf9e451\",\n \"user_name\": \"@i18n@9\",\n \"start_time\": \"1752221889000\",\n \"end_time\": \"1752221889000\",\n \"update_time\": \"1752221889000\",\n \"display_method\": \"BROWSER\",\n \"update_mode\": \"UPDATE\",\n \"task_list\": [\n {\n \"task_id\": \"1154324404224876544\",\n \"user_id\": \"ggf9e451\",\n \"title\": \"@i18n@4\",\n \"links\": {\n \"pc_link\": \"http://10.60.4.124:30609/sp/workflow/flowpage/view/1154324404224876544\",\n \"mobile_link\": \"http://10.60.4.124:30609/sp/workflow/flowpage/view/1154324404224876544\"\n },\n \"status\": \"PENDING\",\n \"extra\": \"{\\\"测试2\\\":\\\"范围2\\\"}\",\n \"create_time\": \"1752221889000\",\n \"end_time\": \"1752221889000\",\n \"update_time\": \"1752221889000\",\n \"action_context\": \"1154324404224876544\",\n \"action_configs\": [\n {\n \"action_type\": \"APPROVE\",\n \"action_name\": \"@i18n@5\",\n \"is_need_reason\": false,\n \"is_reason_required\": false,\n \"is_need_attachment\": false\n }\n ],\n \"display_method\": \"BROWSER\",\n \"exclude_statistics\": false\n \n }\n ],\n \"i18n_resources\": [\n {\n \"locale\": \"zh-CN\",\n \"texts\": [\n {\n \"key\": \"@i18n@1\",\n \"value\": \"招聘需求申请流程\"\n },\n {\n \"key\": \"@i18n@2\",\n \"value\": \"创建人\"\n },\n {\n \"key\": \"@i18n@3\",\n \"value\": \"石磊\"\n },\n {\n \"key\": \"@i18n@4\",\n \"value\": \"招聘需求申请流程--sysadmin\"\n },{\n \"key\": \"@i18n@5\",\n \"value\": \"批准\"\n },\n {\n \"key\": \"@i18n@9\",\n \"value\": \"石磊\"\n },\n {\n \"key\": \"@i18n@10\",\n \"value\": \"运营支持部\"\n },\n {\n \"key\": \"@i18n@name\",\n \"value\": \"部门经理审批\"\n }\n ],\n \"is_default\": true\n }\n ]\n}"
OkHttpClient client = new OkHttpClient().newBuilder()
@ -136,14 +137,24 @@ public class Esb2FeishuSendTodoUtil {
.build();
Response response = client.newCall(request).execute();
int code = response.code();
String msg = response.body().string();
log.error("todo-code:{}",code);
msg = response.body().string();
log.error("todo-msg:"+msg);
okHttpDto.setResponseCode(code);
okHttpDto.setResponseBody(msg);
if(StringUtils.isNotBlank(msg)){
JSONObject returnData = JSONObject.parseObject(msg);
if(returnData.containsKey("code")){
int dataCode = Integer.valueOf(returnData.getString("code"));
okHttpDto.setDataCode(dataCode);
}
}
} catch (IOException e) {
log.error("e:"+e);
throw new RuntimeException(e);
}
return msg;
return okHttpDto;
}
public String appendBodyParam(String requestid,

View File

@ -4,12 +4,12 @@ package com.weaver.seconddev.chapanda.qunjie.constant;
public class Constants {
public static String TENANT_KEY = "t024j0gfn0";
public static String SysUserId = "1167276462243069953";
public static String qunjieHost = "http://110.185.172.132:9242";
public static String qunjieHost = "https://smart-seals.chabaidao.com:8008";
public static String tokenUrl = "/api/token/getToken";
public static String restname = "apiadmin";
public static String password = "cbd@12345";
public static String restname = "cbdadmin";
public static String password = "cbd123456";
public static String querySealUrl = "/api/seal/queryAllSealBase";

View File

@ -31,16 +31,17 @@ public class Esb2QunjieCreateSealApplyAction implements EsbServerlessRpcRemoteIn
log.error("applyCrossPageSealCount:{}",applyCrossPageSealCount);
String fileid = (String) params.get("fileid");
String jobNum = (String) params.get("jobNum");
log.error("fileid:{}",fileid);
if(StringUtils.isBlank(sealId)){
return WeaResult.fail(500,"获取印章信息为空");
}
if(StringUtils.isBlank(fileid)){
return WeaResult.fail(500,"用印文件为空");
}
// if(StringUtils.isBlank(fileid)){
// return WeaResult.fail(500,"用印文件为空");
// }
Long longFileId = 0L;
try{
longFileId = Long.valueOf(fileid);
@ -68,7 +69,7 @@ public class Esb2QunjieCreateSealApplyAction implements EsbServerlessRpcRemoteIn
return WeaResult.fail(500,"用印次数和骑缝章次数不能同时小等于0");
}
Map<String, Object> dataMap = esb2QunjieCreateApplySealUtil.applySealRequest(requestName,sealId,applyCount,applyCrossPageSealCount,longFileId);
Map<String, Object> dataMap = esb2QunjieCreateApplySealUtil.applySealRequest(requestName,sealId,applyCount,applyCrossPageSealCount,longFileId,jobNum);
String applyId = String.valueOf(dataMap.get("applyId"));
String workflowBaseId = String.valueOf(dataMap.get("workflowBaseId"));

View File

@ -31,6 +31,8 @@ public class Esb2QunjieEconomicCompensationAction implements EsbServerlessRpcRem
log.error("requestid:{}",requestid);
log.error("requestName:{}",requestName);
String jobNum = String.valueOf(params.get("jobNum"));
// String sealId = (String) params.get("sealId");
// String applyCount = (String) params.get("applyCount");
// String applyCrossPageSealCount = (String) params.get("applyCrossPageSealCount");
@ -76,7 +78,7 @@ public class Esb2QunjieEconomicCompensationAction implements EsbServerlessRpcRem
// return WeaResult.fail(500,"用印次数和骑缝章次数不能同时小等于0");
// }
Map<String, Object> dataMap = esb2QunjieEconomicCompensationUtil.applySealRequest(requestid,requestName,fileids);
Map<String, Object> dataMap = esb2QunjieEconomicCompensationUtil.applySealRequest(requestid,requestName,fileids,jobNum);
String status = String.valueOf(dataMap.get("status"));
if(!"0".equals(status)){

View File

@ -48,7 +48,7 @@ public class Esb2QunjieCreateApplySealUtil {
@Autowired
private FileDownloadService fileDownloadService;
public Map<String, Object> applySealRequest(String requestName,String sealId,String applyCount,String applyCrossPageSealCount,Long fileid) {
public Map<String, Object> applySealRequest(String requestName,String sealId,String applyCount,String applyCrossPageSealCount,Long fileid,String jobNum) {
log.error("applySealRequest start");
Map<String, Object> messageMap = new HashMap<String, Object>();
@ -109,7 +109,10 @@ public class Esb2QunjieCreateApplySealUtil {
optionJson.put("compound",Constants.compound);
JSONObject bodyJson = new JSONObject();
bodyJson.put("title",requestName);
bodyJson.put("applyerUserName",Constants.applyerUserName);
// bodyJson.put("applyerUserName",Constants.applyerUserName);
bodyJson.put("applyerUserName",jobNum);
bodyJson.put("usedSealParamList",usedSealParamList);
bodyJson.put("option",optionJson);

View File

@ -48,7 +48,7 @@ public class Esb2QunjieEconomicCompensationUtil {
@Autowired
SealsManageDao sealsManageDao;
public Map<String, Object> applySealRequest(String requestid,String requestName,String fileids) {
public Map<String, Object> applySealRequest(String requestid,String requestName,String fileids,String jobNum) {
Map<String, Object> messageMap = new HashMap<String, Object>();
// MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MediaType.get("multipart/form-data;charset=utf-8"));
@ -126,7 +126,9 @@ public class Esb2QunjieEconomicCompensationUtil {
optionJson.put("compound",Constants.compound);
bodyJson.put("title",requestName);
bodyJson.put("applyerUserName",Constants.applyerUserName);
// bodyJson.put("applyerUserName",Constants.applyerUserName);
bodyJson.put("applyerUserName",jobNum);
bodyJson.put("usedSealParamList",usedSealParamList);
bodyJson.put("option",optionJson);
}

View File

@ -4,6 +4,7 @@ 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.sap.entity.OkHttpDto;
import com.weaver.seconddev.chapanda.sap.util.Esb2SapIncorporatedCompanyUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -11,7 +12,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("Esb2SapIncorporatedCompanyCron")
@ -24,14 +24,10 @@ public class Esb2SapIncorporatedCompanyCron implements EsbServerlessRpcRemoteInt
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
log.error("Esb2QunjieTestAttachmentCron");
// List<Map<String,Object>> dataList
// OkHttpDto okHttpDto = esb2SapIncorporatedCompanyUtil.queryIF311List();
//
// log.error("getResponseCode:{}",okHttpDto.getResponseCode());
//
// if(okHttpDto.getResponseCode() == 200){
// JSONObject dataJson = okHttpDto.getDataJson();
JSONObject dataJson = convertData();
OkHttpDto okHttpDto = esb2SapIncorporatedCompanyUtil.queryIF311List();
log.error("getResponseCode:{}",okHttpDto.getResponseCode());
if(okHttpDto.getResponseCode() == 200){
JSONObject dataJson = okHttpDto.getDataJson();
JSONArray dataList = new JSONArray();
if(dataJson.containsKey("data")){
dataList = dataJson.getJSONArray("data");
@ -53,14 +49,12 @@ public class Esb2SapIncorporatedCompanyCron implements EsbServerlessRpcRemoteInt
*/
esb2SapIncorporatedCompanyUtil.updateDeptEmployeeCostCenter(dataList);
}
// else{
// return WeaResult.fail(500,"SAP接口获取为空");
// }
// }else{
// return WeaResult.fail(500,okHttpDto.getDataMsg());
// }
// esb2SapIncorporatedCompanyUtil.updateEmployeeCostCenter(dataList);
else{
return WeaResult.fail(500,"SAP接口获取为空");
}
}else{
return WeaResult.fail(500,okHttpDto.getDataMsg());
}
Map<String, Object> actionMap = new HashMap<String, Object>();
actionMap.put("code",200);
@ -69,8 +63,6 @@ public class Esb2SapIncorporatedCompanyCron implements EsbServerlessRpcRemoteInt
return WeaResult.success(actionMap);
}
public JSONObject convertData(){
log.error("convertData");
JSONArray bodyArray = new JSONArray();