Compare commits
No commits in common. "release" and "main" have entirely different histories.
|
|
@ -0,0 +1,26 @@
|
|||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.cache;
|
||||
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.common.cache.base.ModuleCacheInterface;
|
||||
import com.weaver.common.cache.base.exception.IllegalCacheAccessException;
|
||||
import com.weaver.seconddev.chapanda.beisen.module.BeisenTokenModuleKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 集成缓存类
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
@Component
|
||||
public class BeisenTokenCacheKey implements ModuleCacheInterface {
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
//科大accesstoken
|
||||
public final static String BEISEN_TOKEN = "BEISEN_TOKEN";
|
||||
|
||||
@Override
|
||||
public void register() throws IllegalCacheAccessException, IllegalAccessException {
|
||||
baseCache.register(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, this.getClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1147262704872284161";
|
||||
|
||||
public static String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
public static String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
public static String tokenUrl = "https://openapi.italent.cn/token";
|
||||
|
||||
public static String beishenHost = "https://openapi.italent.cn";
|
||||
public static String createBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/Create";
|
||||
public static String deleteBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/BatchDelete";
|
||||
|
||||
public static String offerUrl = "/TenantBaseExternal/api/v5/Offer/GetByTimeWindow";
|
||||
|
||||
public static String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
public static String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
|
||||
public static String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
|
||||
public static String userInfoUrl = "/UserFrameworkApiV3/api/v1/staffs/Get";
|
||||
|
||||
public static String deppartmentUrl = "/UserFrameworkApiV3/api/v1/departments/Get";
|
||||
|
||||
public static String jobRequirementUrl = "/RecruitV6/api/v1/Requirement/CreateRequirement";
|
||||
|
||||
public static String assessmentFormTable = "uf_jxsjtz";
|
||||
|
||||
public static String assessmentFilterUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByFilters";
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.controller;
|
||||
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbdhr/annual")
|
||||
public class ConversionResignController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ConversionResignController.class);
|
||||
|
||||
@Autowired
|
||||
ConversionResignService conversionResignService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/resignConversion")
|
||||
public WeaResult<Object> resignConversion(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
Map<String,Object> recordMap = conversionResignService.resignConversion(paraMap);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/resignConversion2")
|
||||
public WeaResult<Object> resignConversion2(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String,Object> paraMap = CommonUtils.requestToMap(request);
|
||||
Map<String,Object> recordMap = conversionResignService.resignConversion2(paraMap);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.controller;
|
||||
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.EmployeePointsDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbdhr/points")
|
||||
public class EmployeePointsController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(EmployeePointsController.class);
|
||||
|
||||
@Autowired
|
||||
ConversionResignService conversionResignService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@Autowired
|
||||
EmployeePointsDao employeePointsDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderUtils ebuilderUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/getpoints")
|
||||
public WeaResult<Object> resignConversion(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
List<Map<String, Object>> interviewerList = employeePointsDao.queryInterviewerList();
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
log.error("interviewerList:"+interviewerList.size());
|
||||
recordMap.put("interviewerList",interviewerList.size());
|
||||
recordList.add(recordMap);
|
||||
|
||||
for(int i=0;i<interviewerList.size();i++){
|
||||
|
||||
recordMap = new HashMap<String,Object>();
|
||||
|
||||
/**
|
||||
* 招聘阶段
|
||||
*/
|
||||
String stage_id = String.valueOf(interviewerList.get(i).get("stage_id"));
|
||||
/**
|
||||
* 人才ID
|
||||
*/
|
||||
String talent_id = String.valueOf(interviewerList.get(i).get("talent_id"));
|
||||
/***
|
||||
* 推荐人ID
|
||||
*/
|
||||
String referrer_id = String.valueOf(interviewerList.get(i).get("referrer_id"));
|
||||
|
||||
|
||||
log.error("stage_id:"+stage_id);
|
||||
log.error("talent_id:"+talent_id);
|
||||
log.error("referrer_id:"+referrer_id);
|
||||
|
||||
recordMap.put("stage_id",stage_id);
|
||||
recordMap.put("talent_id",talent_id);
|
||||
recordMap.put("referrer_id",referrer_id);
|
||||
|
||||
int points = 0;
|
||||
|
||||
/***
|
||||
* 出试
|
||||
*/
|
||||
if("937153853968544649".equals(stage_id)){
|
||||
points = 100;
|
||||
|
||||
}else if("937153853968544650".equals(stage_id)){
|
||||
/***
|
||||
* 部门筛选
|
||||
*/
|
||||
points = 200;
|
||||
}else if("937153853968544653".equals(stage_id)){
|
||||
/***
|
||||
* 待入职
|
||||
*/
|
||||
points = 500;
|
||||
}
|
||||
log.error("points:{}",points);
|
||||
|
||||
recordMap.put("points",points);
|
||||
|
||||
if(points > 0){
|
||||
Map<String,Object> pointsMap = employeePointsDao.queryPointsByEmployeeId(referrer_id);
|
||||
/***
|
||||
* 积分主表id
|
||||
*/
|
||||
String mainid = String.valueOf(pointsMap.get("id"));
|
||||
if("null".equals(mainid) || mainid == null){
|
||||
mainid = "";
|
||||
}
|
||||
/**
|
||||
* 积分主表form_data_id
|
||||
*/
|
||||
String pointsFormDataId= String.valueOf(pointsMap.get("form_data_id"));
|
||||
if("null".equals(pointsFormDataId) || pointsFormDataId == null){
|
||||
pointsFormDataId = "";
|
||||
}
|
||||
|
||||
log.error("mainid:{}",mainid);
|
||||
log.error("pointsFormDataId:{}",pointsFormDataId);
|
||||
|
||||
recordMap.put("mainid",mainid);
|
||||
recordMap.put("pointsFormDataId",pointsFormDataId);
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = null;
|
||||
if(StringUtils.isNotBlank(mainid)){
|
||||
|
||||
recordMap.put("num","1");
|
||||
String detailId = employeePointsDao.queryPointsDeatilByEmployeeId(talent_id,pointsFormDataId);
|
||||
log.error("detailId:{}",detailId);
|
||||
|
||||
recordMap.put("detailId",detailId);
|
||||
if(StringUtils.isNotBlank(detailId)){
|
||||
recordMap.put("num","2");
|
||||
employeePointsDao.updatePointsDeatilByFormDataId(talent_id,pointsFormDataId,points);
|
||||
employeePointsDao.updatePointsTotalByFormDataId(pointsFormDataId);
|
||||
|
||||
}else{
|
||||
recordMap.put("num","3");
|
||||
ebDataChangeResult = ebuilderUtils.bacthAppendEbDetail(talent_id,points,pointsFormDataId);
|
||||
boolean status = false;
|
||||
String message = "";
|
||||
if(ebDataChangeResult != null){
|
||||
status = ebDataChangeResult.getStatus() ;
|
||||
message = ebDataChangeResult.getMessage();
|
||||
}
|
||||
log.error("message:{}",message);
|
||||
if(status){
|
||||
employeePointsDao.updatePointsTotalByFormDataId(pointsFormDataId);
|
||||
}
|
||||
recordMap.put("status",status);
|
||||
recordMap.put("message",message);
|
||||
}
|
||||
}else{
|
||||
recordMap.put("num","4");
|
||||
ebDataChangeResult = ebuilderUtils.bacthInsertDbForm(referrer_id,points,talent_id);
|
||||
boolean status = false;
|
||||
String message = "";
|
||||
if(ebDataChangeResult != null){
|
||||
status = ebDataChangeResult.getStatus() ;
|
||||
message = ebDataChangeResult.getMessage();
|
||||
}
|
||||
log.error("message:{}",message);
|
||||
log.error("status:{}",status);
|
||||
|
||||
recordMap.put("status",status);
|
||||
recordMap.put("message",message);
|
||||
|
||||
}
|
||||
}else{
|
||||
recordMap.put("message","积分为空");
|
||||
}
|
||||
recordList.add(recordMap);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("message",e.getMessage());
|
||||
recordList.add(recordMap);
|
||||
}
|
||||
return WeaResult.success(recordList);
|
||||
}
|
||||
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/test")
|
||||
public WeaResult<Object> test(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Map<String, Object> recordMap = new HashMap<String,Object>();
|
||||
recordMap.put("test","test");
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class ConversionResignDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConversionResignDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryEmployeeById(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String hiredate = "";
|
||||
try{
|
||||
String dataSql =" select hiredate " +
|
||||
" from eteams.employee " +
|
||||
" where id = '"+employeeId+"' \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = '"+Constants.TENANT_KEY+"' " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
hiredate = String.valueOf(recordMap.get("hiredate"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return hiredate;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param employeeid
|
||||
* @param lznf
|
||||
* @return
|
||||
*/
|
||||
public Double queryEmployeeAnnualLeave(String employeeid,String lznf){
|
||||
String groupId = "weaver-salary-report";
|
||||
String sourceType = "LOGIC";
|
||||
Double annualBase = 0.0;
|
||||
try{
|
||||
String dataSql =" select base " +
|
||||
" from attend_vacation_info_v2 " +
|
||||
" where employee = ? \n" +
|
||||
" and year = ? " +
|
||||
" and tenant_key= ?\n" +
|
||||
" and DELETE_TYPE = 0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
|
||||
paramList.add(employeeid);
|
||||
paramList.add(lznf);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
String base = String.valueOf(recordMap.get("base"));
|
||||
if(StringUtils.isNotBlank(base)){
|
||||
annualBase = Double.valueOf(base);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
annualBase = 0.0 ;
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return annualBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,234 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class EmployeePointsDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EmployeePointsDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
public Map<String,Object> queryPointsByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select id,form_data_id " +
|
||||
" from uf_jfgl " +
|
||||
" where ry = ? \n" +
|
||||
" and delete_type=0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> queryInterviewerList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>(100);
|
||||
try{
|
||||
// String dataSql =" select id,referrer_id,recruit_status " +
|
||||
// " from uf_rcrt_talent " +
|
||||
// " where referrer_id is not null \n" +
|
||||
// " and delete_type=0 \n" +
|
||||
// " and tenant_key = ? " ;
|
||||
|
||||
String dataSql =" select t.id,\n" +
|
||||
" t.talent_id,\n" +
|
||||
" t.stage_id,\n" +
|
||||
" t.candidate_id,\n" +
|
||||
" k.referrer_id\n" +
|
||||
" from uf_rcrt_candidate_stage t \n" +
|
||||
" inner join uf_rcrt_candidate_batch p on p.id = t.candidate_id\n" +
|
||||
" left join uf_rcrt_talent k on k.id = t.talent_id\n" +
|
||||
" where t.arrive_status =1\n" +
|
||||
" and p.archive_status = '840811264954613765' " +
|
||||
" and t.delete_type=0 \n" +
|
||||
" and t.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" and k.delete_type=0 \n" +
|
||||
" and k.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" and p.delete_type=0 \n" +
|
||||
" and p.tenant_key = '"+Constants.TENANT_KEY+"' " +
|
||||
" " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<String>(100);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}" ,recordList.size());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
|
||||
public String queryPointsDeatilByEmployeeId(String rcid,String form_data_id){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String detailId = "";
|
||||
try{
|
||||
String dataSql =" select id,form_data_id " +
|
||||
" from uf_jfgl_mxb1 " +
|
||||
" where rcxx = ? " +
|
||||
" and form_data_id = ? \n" +
|
||||
" and delete_type=0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:{}" , dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(rcid);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:{}",recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
detailId = String.valueOf(recordMap.get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:{}" , e);
|
||||
}
|
||||
return detailId;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> updatePointsDeatilByFormDataId(String rcid,String form_data_id,int jf){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" update uf_jfgl_mxb1 set hqjf = " + jf +
|
||||
" where rcxx = ? and form_data_id = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(rcid);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> updatePointsTotalByFormDataId(String form_data_id){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" update uf_jfgl set jf = (select ifnull(sum(hqjf),0) as hqjf from uf_jfgl_mxb1 where form_data_id= ? and delete_type = 0 and tenant_key = ? ) " +
|
||||
" where form_data_id = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(form_data_id);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param employeeid
|
||||
* @param lznf
|
||||
* @return
|
||||
*/
|
||||
public Double queryEmployeeAnnualLeave(String employeeid,String lznf){
|
||||
String groupId = "weaver-salary-report";
|
||||
String sourceType = "LOGIC";
|
||||
Double annualBase = 0.0;
|
||||
try{
|
||||
String dataSql =" select base " +
|
||||
" from attend_vacation_info_v2 " +
|
||||
" where employee = ? \n" +
|
||||
" and year = ? " +
|
||||
" and tenant_key= ?\n" +
|
||||
" and DELETE_TYPE = 0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
|
||||
paramList.add(employeeid);
|
||||
paramList.add(lznf);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String,Object> recordMap = recordList.get(0);
|
||||
String base = String.valueOf(recordMap.get("base"));
|
||||
if(StringUtils.isNotBlank(base)){
|
||||
annualBase = Double.valueOf(base);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
annualBase = 0.0 ;
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return annualBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(FormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryDepartmentList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select code,id from eteams.department and tenant_key=? and delete_type=0" ;
|
||||
log.error("queryDepartmentList--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public String getGmvIdByCode(String code,String formTable,String dataKey){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String dataId = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select id from "+formTable+" and tenant_key=? and delete_type=0 and "+dataKey+"=?" ;
|
||||
log.error("dataSql:{}", dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(code);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
dataId = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class HrmDepartmentDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(HrmDepartmentDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public String getDepartmentCodeById(String deptId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String code = "";
|
||||
try{
|
||||
String dataSql =" select code from eteams.department where id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(deptId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("getDepartmentCodeById:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
code = String.valueOf(recordList.get(0).get("code"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("getDepartmentCodeById:e:" + e);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public String queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String form_id = "";
|
||||
try{
|
||||
String dataSql =" select form_id from form_table where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
Map<String, Object> recordMap = recordList.get(0);
|
||||
form_id = String.valueOf(recordMap.get("form_id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return form_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from eteams.form_field " +
|
||||
" where form_id in( select form_id from eteams.form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String queryEmailByEmployeeId(String employeeId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
String gryx = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select k.gryx from eteams.employee t\n" +
|
||||
" inner join eteams.ft_1152026012537184302 k on k.id = t.formdata\n" +
|
||||
" where t.id=? " +
|
||||
" and t.tenant_key=? \n" +
|
||||
" and t.delete_type=0" +
|
||||
" and k.tenant_key=? \n" +
|
||||
" and k.delete_type=0";
|
||||
|
||||
log.error("queryEmailByEmployeeId--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(employeeId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryEmailByEmployeeId:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
gryx = String.valueOf(recordList.get(0).get("gryx"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("queryEmailByEmployeeId:e:" + e);
|
||||
}
|
||||
return gryx;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryDepartmentData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select code,id from eteams.department where status = 1 " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0 " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Object> queryEmployeeData(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
|
||||
try{
|
||||
String dataSql =" select job_num,id from eteams.employee where tenant_key=? and delete_type = 0" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String, Object> recordMap = recordList.get(i);
|
||||
String job_num = String.valueOf(recordMap.get("job_num"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(job_num,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenDepartmentDto {
|
||||
int orgId;
|
||||
String name;
|
||||
String code;
|
||||
String abbreviation;
|
||||
String parentOriginalId;
|
||||
String originalId;
|
||||
String status;
|
||||
String isDelete;
|
||||
String orderId;
|
||||
|
||||
public int getOrgId() {
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public void setOrgId(int orgId) {
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getParentOriginalId() {
|
||||
return parentOriginalId;
|
||||
}
|
||||
|
||||
public void setParentOriginalId(String parentOriginalId) {
|
||||
this.parentOriginalId = parentOriginalId;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenHireRequestDto {
|
||||
int requirementStatus;
|
||||
int requirementType;
|
||||
String name;
|
||||
int createBy;
|
||||
String createDate;
|
||||
String arivalTime;
|
||||
String dutyUserEmail;
|
||||
String createByEmail;
|
||||
int departmentId;
|
||||
int requirementCount;
|
||||
int salaryType;
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffDepartmentDto {
|
||||
String id;
|
||||
String name;
|
||||
String code;
|
||||
String abbreviation;
|
||||
String parentId;
|
||||
String level;
|
||||
String status;
|
||||
String originalId;
|
||||
String isDelete;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,286 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffDto {
|
||||
String departmentId;
|
||||
String departmentName;
|
||||
String employedDate;
|
||||
String jobCode;
|
||||
String positionName;
|
||||
String lineManagerId;
|
||||
String staffCode;
|
||||
String staffStatus;
|
||||
String isDelete;
|
||||
int userId;
|
||||
String tenantId;
|
||||
String email;
|
||||
String userType;
|
||||
String userStatus;
|
||||
String origin;
|
||||
String originalId;
|
||||
String name;
|
||||
String englishName;
|
||||
String sex;
|
||||
|
||||
String birthday;
|
||||
String mobile;
|
||||
String idCardType;
|
||||
String idCardNumber;
|
||||
String graduateDate;
|
||||
String nativePlace;
|
||||
String beganWorkDate;
|
||||
String graduateFrom;
|
||||
String major;
|
||||
String positionCategory;
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto;
|
||||
BeisenStaffPositionDto beisenStaffPositionDto;
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName;
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public String getEmployedDate() {
|
||||
return employedDate;
|
||||
}
|
||||
|
||||
public void setEmployedDate(String employedDate) {
|
||||
this.employedDate = employedDate;
|
||||
}
|
||||
|
||||
public String getJobCode() {
|
||||
return jobCode;
|
||||
}
|
||||
|
||||
public void setJobCode(String jobCode) {
|
||||
this.jobCode = jobCode;
|
||||
}
|
||||
|
||||
public String getPositionName() {
|
||||
return positionName;
|
||||
}
|
||||
|
||||
public void setPositionName(String positionName) {
|
||||
this.positionName = positionName;
|
||||
}
|
||||
|
||||
public String getLineManagerId() {
|
||||
return lineManagerId;
|
||||
}
|
||||
|
||||
public void setLineManagerId(String lineManagerId) {
|
||||
this.lineManagerId = lineManagerId;
|
||||
}
|
||||
|
||||
public String getStaffCode() {
|
||||
return staffCode;
|
||||
}
|
||||
|
||||
public void setStaffCode(String staffCode) {
|
||||
this.staffCode = staffCode;
|
||||
}
|
||||
|
||||
public String getStaffStatus() {
|
||||
return staffStatus;
|
||||
}
|
||||
|
||||
public void setStaffStatus(String staffStatus) {
|
||||
this.staffStatus = staffStatus;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(String userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
public String getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(String origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public void setOriginalId(String originalId) {
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEnglishName() {
|
||||
return englishName;
|
||||
}
|
||||
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(String birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getIdCardType() {
|
||||
return idCardType;
|
||||
}
|
||||
|
||||
public void setIdCardType(String idCardType) {
|
||||
this.idCardType = idCardType;
|
||||
}
|
||||
|
||||
public String getIdCardNumber() {
|
||||
return idCardNumber;
|
||||
}
|
||||
|
||||
public void setIdCardNumber(String idCardNumber) {
|
||||
this.idCardNumber = idCardNumber;
|
||||
}
|
||||
|
||||
public String getGraduateDate() {
|
||||
return graduateDate;
|
||||
}
|
||||
|
||||
public void setGraduateDate(String graduateDate) {
|
||||
this.graduateDate = graduateDate;
|
||||
}
|
||||
|
||||
public String getNativePlace() {
|
||||
return nativePlace;
|
||||
}
|
||||
|
||||
public void setNativePlace(String nativePlace) {
|
||||
this.nativePlace = nativePlace;
|
||||
}
|
||||
|
||||
public String getBeganWorkDate() {
|
||||
return beganWorkDate;
|
||||
}
|
||||
|
||||
public void setBeganWorkDate(String beganWorkDate) {
|
||||
this.beganWorkDate = beganWorkDate;
|
||||
}
|
||||
|
||||
public String getGraduateFrom() {
|
||||
return graduateFrom;
|
||||
}
|
||||
|
||||
public void setGraduateFrom(String graduateFrom) {
|
||||
this.graduateFrom = graduateFrom;
|
||||
}
|
||||
|
||||
public String getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public void setMajor(String major) {
|
||||
this.major = major;
|
||||
}
|
||||
|
||||
public String getPositionCategory() {
|
||||
return positionCategory;
|
||||
}
|
||||
|
||||
public void setPositionCategory(String positionCategory) {
|
||||
this.positionCategory = positionCategory;
|
||||
}
|
||||
|
||||
public BeisenStaffDepartmentDto getBeisenStaffDepartmentDto() {
|
||||
return beisenStaffDepartmentDto;
|
||||
}
|
||||
|
||||
public void setBeisenStaffDepartmentDto(BeisenStaffDepartmentDto beisenStaffDepartmentDto) {
|
||||
this.beisenStaffDepartmentDto = beisenStaffDepartmentDto;
|
||||
}
|
||||
|
||||
public BeisenStaffPositionDto getBeisenStaffPositionDto() {
|
||||
return beisenStaffPositionDto;
|
||||
}
|
||||
|
||||
public void setBeisenStaffPositionDto(BeisenStaffPositionDto beisenStaffPositionDto) {
|
||||
this.beisenStaffPositionDto = beisenStaffPositionDto;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.entity;
|
||||
|
||||
|
||||
public class BeisenStaffPositionDto {
|
||||
String id;
|
||||
String name;
|
||||
String code;
|
||||
String status;
|
||||
String isDelete;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(String isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,98 +0,0 @@
|
|||
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.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.BeisenStaffInfoByStaffCodeUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.BlackList2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenCreateBlackListAction")
|
||||
public class Esb2BeisenCreateBlackListAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenCreateBlackListAction.class);
|
||||
|
||||
@Autowired
|
||||
BlackList2BeiSenUtil blackList2BeiSenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
BeisenStaffInfoByStaffCodeUtil beisenStaffInfoByStaffCodeUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("EsbRequestSubmitAction start");
|
||||
// String beisenUserId = (String) params.get("beisenuserid");
|
||||
Long userId = 0L;
|
||||
if(params.containsKey("userid")){
|
||||
String userIdStr = String.valueOf(params.get("userid"));
|
||||
log.error("userIdStr:{}",userIdStr);
|
||||
if(StringUtils.isNotBlank(userIdStr)){
|
||||
userId = Long.parseLong(userIdStr);
|
||||
}
|
||||
}
|
||||
|
||||
String lastWorkDate = (String) params.get("lastworkdate");
|
||||
String blackAddReason = (String) params.get("blackaddreason");
|
||||
String blackStaffDesc = (String) params.get("blackstaffdesc");
|
||||
String name = (String) params.get("name");
|
||||
String staffemail = (String) params.get("staffemail");
|
||||
|
||||
log.error("userId:{}",userId);
|
||||
log.error("lastWorkDate:{}",lastWorkDate);
|
||||
log.error("blackAddReason:{}",blackAddReason);
|
||||
log.error("blackStaffDesc:{}",blackStaffDesc);
|
||||
log.error("name:{}",name);
|
||||
log.error("staffemail:{}",staffemail);
|
||||
int beisenUserId = -1;
|
||||
String jobNum = "";
|
||||
if(userId >0){
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(userId);
|
||||
jobNum = simpleEmployee.getJobNum();
|
||||
}
|
||||
|
||||
log.error("jobNum:{}",jobNum);
|
||||
if(StringUtils.isNotBlank(jobNum)){
|
||||
BeisenStaffDto beisenStaffDto = beisenStaffInfoByStaffCodeUtil.getBeisenStaffInfoByStaffCode(jobNum);
|
||||
beisenUserId = beisenStaffDto.getUserId();
|
||||
}
|
||||
log.error("beisenUserId:{}",beisenUserId);
|
||||
|
||||
// String tokenUrl = "https://openapi.italent.cn/token";
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
// String createBlackListUrl = "/TenantBaseExternal/api/v5/BlackList/Create";
|
||||
// String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
// String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
String objectId = "";
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
if(beisenUserId > 0){
|
||||
objectId = blackList2BeiSenUtil.createBlackList4ResignUser(token,String.valueOf(beisenUserId),lastWorkDate,blackAddReason,blackStaffDesc);
|
||||
}else{
|
||||
objectId = blackList2BeiSenUtil.createBlackList4NonSystem(token,name,staffemail,blackAddReason,blackStaffDesc);
|
||||
}
|
||||
}
|
||||
|
||||
log.error("objectId:{}",objectId);
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenCreateBlackListAction");
|
||||
actionMap.put("objectId",objectId);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.BlackList2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenDeleteBlackListAction")
|
||||
public class Esb2BeisenDeleteBlackListAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenDeleteBlackListAction.class);
|
||||
|
||||
@Autowired
|
||||
BlackList2BeiSenUtil blackList2BeiSenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenDeleteBlackListAction start");
|
||||
String objectIds = (String) params.get("objectIds");
|
||||
log.error("objectIds:{}",objectIds);
|
||||
|
||||
String msg = "";
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
List<String> userIds = Arrays.asList(objectIds.split(","));
|
||||
msg = blackList2BeiSenUtil.batchDeleteBlackList(token,userIds);
|
||||
}
|
||||
|
||||
String failDatas = "";
|
||||
int failCount = -1 ;
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("failCount")){
|
||||
failCount = dataObject.getInteger("failCount");
|
||||
failDatas = dataObject.getString("failDatas");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenDeleteBlackListAction");
|
||||
actionMap.put("failCount",failCount);
|
||||
actionMap.put("failDatas",failDatas);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.cache.HrmDepartmentComInfo;
|
||||
import com.weaver.common.hrm.manage.HrmComInfoCacheHandler;
|
||||
import com.weaver.common.hrm.remote.department.HrmRemoteDepartmentService;
|
||||
import com.weaver.common.hrm.service.HrmCommonDepartmentService;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmDepartmentDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.*;
|
||||
import com.weaver.teams.domain.department.SimpleDepartment;
|
||||
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenJobRequirementAction")
|
||||
public class Esb2BeisenJobRequirementAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenJobRequirementAction.class);
|
||||
|
||||
@Autowired
|
||||
JobRequirement2BeisenUtil jobRequirement2BeisenUtil;
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
DatabaseUtils databaseUtils;
|
||||
|
||||
@Autowired
|
||||
BeisenStaffInfoByStaffCodeUtil beisenStaffInfoByStaffCodeUtil ;
|
||||
|
||||
@Autowired
|
||||
BeisenDeptInfoByOriginalIdUtil beisenDeptInfoByOriginalIdUtil;
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmDepartmentDao hrmDepartmentDao;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenJobRequirementAction start");
|
||||
|
||||
int requirementStatus = converInteger(params,"requirementStatus");
|
||||
String form_data_id = (String) params.get("form_data_id");
|
||||
int requirementType = converInteger(params,"requirementType");
|
||||
|
||||
String requestname = (String) params.get("requestname");
|
||||
String createDate = (String) params.get("createDate");
|
||||
|
||||
|
||||
int requirementCount = converInteger(params,"requirementCount") ;
|
||||
String arivalTime = (String) params.get("arivalTime");
|
||||
|
||||
int salaryType = converInteger(params,"salaryType");
|
||||
int category = converInteger(params,"category");
|
||||
String educationInfo = (String) params.get("educationInfo");
|
||||
String workExperience = (String) params.get("workExperience");
|
||||
int kind = converInteger(params,"kind");
|
||||
boolean isSecrecy = false;
|
||||
String isSecrecyStr = (String) params.get("isSecrecy");
|
||||
if("1".equals(isSecrecyStr)){
|
||||
isSecrecy = true;
|
||||
}
|
||||
|
||||
String originalId = String.valueOf(params.get("originalId"));
|
||||
|
||||
log.error("requirementStatus:" + requirementStatus);
|
||||
log.error("originalId:" + originalId);
|
||||
log.error("requirementType:" + requirementType);
|
||||
log.error("requestname:" + requestname);
|
||||
log.error("createDate:" + createDate);
|
||||
log.error("requirementCount:" + requirementCount);
|
||||
log.error("arivalTime:" + arivalTime);
|
||||
log.error("salaryType:" + salaryType);
|
||||
log.error("category:" + category);
|
||||
log.error("educationInfo:" + educationInfo);
|
||||
log.error("workExperience:" + workExperience);
|
||||
log.error("kind:" + kind);
|
||||
log.error("isSecrecy:" + isSecrecy);
|
||||
log.error("form_data_id:" + form_data_id);
|
||||
|
||||
String createBy = String.valueOf(params.get("createBy"));
|
||||
String dutyUserId = String.valueOf(params.get("dutyUserId"));
|
||||
log.error("createBy:" + createBy);
|
||||
log.error("dutyUserId:" + dutyUserId);
|
||||
|
||||
|
||||
int beisenUserId = -1;
|
||||
if(StringUtils.isNotBlank(createBy)){
|
||||
String jobnum = "";
|
||||
SimpleEmployee createByEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(createBy));
|
||||
if(createByEmployee !=null && createByEmployee.getId() > 0){
|
||||
jobnum = createByEmployee.getJobNum();
|
||||
}
|
||||
log.error("jobnum:" + jobnum);
|
||||
if(StringUtils.isNotBlank(jobnum)){
|
||||
BeisenStaffDto beisenStaffDto = beisenStaffInfoByStaffCodeUtil.getBeisenStaffInfoByStaffCode(jobnum);
|
||||
if(beisenStaffDto !=null){
|
||||
beisenUserId = beisenStaffDto.getUserId();
|
||||
}
|
||||
log.error("beisenUserId:" + beisenUserId);
|
||||
}
|
||||
}
|
||||
|
||||
String createByEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
log.error("createByEmail:" + createByEmail);
|
||||
String dutyUserEmail = hrmDepartmentDao.queryEmailByEmployeeId(dutyUserId);
|
||||
log.error("dutyUserEmail:" + dutyUserEmail);
|
||||
|
||||
String originalCode = "";
|
||||
if(StringUtils.isNotBlank(originalId)){
|
||||
originalCode = hrmDepartmentDao.getDepartmentCodeById(originalId);
|
||||
}
|
||||
log.error("originalCode:" + originalCode);
|
||||
|
||||
int orgId = -1;
|
||||
if(StringUtils.isNotBlank(originalCode)){
|
||||
BeisenDepartmentDto beisenDepartmentDto = beisenDeptInfoByOriginalIdUtil.getBeisenDeptDataByOriginalId(originalId);
|
||||
log.error("beisenDepartmentDto:{}",beisenDepartmentDto.toString());
|
||||
orgId = beisenDepartmentDto.getOrgId();
|
||||
}
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:" + token);
|
||||
log.error("orgId:" + orgId);
|
||||
String dataId = jobRequirement2BeisenUtil.sendJobRequirement(token,requirementStatus,requirementType,
|
||||
requestname,beisenUserId,
|
||||
createDate,requirementCount,
|
||||
arivalTime,
|
||||
createByEmail,
|
||||
dutyUserEmail,
|
||||
orgId,
|
||||
salaryType,
|
||||
category,
|
||||
educationInfo,
|
||||
workExperience,
|
||||
kind,
|
||||
isSecrecy,
|
||||
originalCode);
|
||||
|
||||
log.error("dataId:" + dataId);
|
||||
// if(StringUtils.isNotBlank(dataId)){
|
||||
// String sourceType = "";
|
||||
// String groupId = "";
|
||||
//
|
||||
// String dataSql =" update uf_zpxqgl set bszxid = ? " +
|
||||
// " where form_data_id = ?\n" +
|
||||
// " and tenant_key=? \n" +
|
||||
// " and delete_type=0 \n" ;
|
||||
//
|
||||
// log.error("dataSql:" + dataSql);
|
||||
// List<String> paramList = new ArrayList<>(100);
|
||||
//
|
||||
// paramList.add(form_data_id);
|
||||
// paramList.add(Constants.TENANT_KEY);
|
||||
// List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
// result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
// }
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenJobRequirementAction");
|
||||
actionMap.put("dataId",dataId);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public int converInteger(Map<String,Object> params,String key){
|
||||
int value = -1;
|
||||
try{
|
||||
String requirementStatusStr = (String) params.get(key);
|
||||
value = Integer.valueOf(requirementStatusStr);
|
||||
}catch (Exception e){
|
||||
log.error("key:{},e:{}",key,e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Offer2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenOfferCronJob")
|
||||
public class Esb2BeisenOfferCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenOfferCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil http2BenSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Offer2BeiSenUtil offer2BeiSenUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("EsbTrainingCronJobAction start");
|
||||
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
// String offerUrl = "/TenantBaseExternal/api/v5/Offer/GetByTimeWindow";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
JSONArray offerArray = new JSONArray();
|
||||
// LocalDate today = LocalDate.now();
|
||||
// LocalDate yesterday = today.minusDays(1);
|
||||
// String startDate = yesterday.toString();
|
||||
// String startTime = sdf.format(new Date());
|
||||
// String endDate = today.toString();
|
||||
// String endTime = sdf.format(new Date());
|
||||
|
||||
String startDate = String.valueOf(params.get("startDate"));
|
||||
String startTime = String.valueOf(params.get("startTime"));
|
||||
String endDate = String.valueOf(params.get("endDate"));
|
||||
String endTime = String.valueOf(params.get("endTime"));
|
||||
|
||||
String token = http2BenSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
offerArray = offer2BeiSenUtil.queryOfferByDateTime(token,startDate, startTime, endDate, endTime);
|
||||
}
|
||||
|
||||
log.error("offerArray:{}",offerArray.toJSONString());
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenOfferCronJob");
|
||||
actionMap.put("offer",offerArray);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Performance2BeiSenUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenPerformanceCronJob")
|
||||
public class Esb2BeisenPerformanceCronJob implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPerformanceCronJob.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Performance2BeiSenUtil performance2BeiSenUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2BeisenPerformanceCronJob start");
|
||||
|
||||
// String tokenUrl = "https://openapi.italent.cn/token";
|
||||
// String beishenHost = "https://openapi.italent.cn";
|
||||
//
|
||||
// String app_key = "0F0F2B3F6356464EB59FB651E8DAACBA";
|
||||
// String app_secret = "AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003";
|
||||
|
||||
// int page = 0;
|
||||
// int capacity = 2;
|
||||
// int year = 2024;
|
||||
// int period = 8;
|
||||
|
||||
String page = String.valueOf(params.get("page")) ;
|
||||
String capacity = String.valueOf(params.get("capacity"));
|
||||
String year = String.valueOf(params.get("year"));
|
||||
String period = String.valueOf(params.get("period"));
|
||||
|
||||
// String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
// String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
// String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
JSONArray activityManagerArray = new JSONArray();
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
activityManagerArray = queryActivityManager(token,page,capacity,year,period);
|
||||
log.error("activityManagerArray:{}",activityManagerArray.toJSONString());
|
||||
queryAssessmentItem(activityManagerArray,token,page,capacity);
|
||||
assessmentArray = queryAssessment(activityManagerArray,token);
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2BeisenPerformanceCronJob");
|
||||
actionMap.put("assessmentArray",assessmentArray);
|
||||
actionMap.put("activityManagerArray",activityManagerArray);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
|
||||
public JSONArray queryActivityManager(String token,String page,String capacity,String year,String period){
|
||||
int activityTotal = 0;
|
||||
JSONArray activityManagerArray = new JSONArray();
|
||||
JSONArray performanceArray = new JSONArray();
|
||||
String bodyData = performance2BeiSenUtil.getActivityManagerCount(token,page,capacity,year,period);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("paging")){
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
activityTotal = pagingJson.getInteger("total");
|
||||
}
|
||||
if(dataObject.containsKey("items")){
|
||||
performanceArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(activityTotal <= Integer.valueOf(capacity)){
|
||||
activityManagerArray = performanceArray;
|
||||
}else{
|
||||
activityManagerArray.addAll(performanceArray);
|
||||
int pageCount = (int)Math.floor(activityTotal / Integer.valueOf(capacity));
|
||||
for(int i = 1; i < pageCount; i++){
|
||||
JSONArray itemArray = performance2BeiSenUtil.queryActivityManager(token,String.valueOf(i),capacity,year,period);
|
||||
activityManagerArray.add(itemArray);
|
||||
}
|
||||
}
|
||||
return activityManagerArray;
|
||||
}
|
||||
|
||||
public void queryAssessmentItem(JSONArray activityManagerArray,String token,String page,String capacity){
|
||||
|
||||
for(int i = 0; i < activityManagerArray.size(); i++){
|
||||
int itemTotal = 0;
|
||||
JSONArray itemsArray = new JSONArray();
|
||||
JSONArray assessmentItemArray = new JSONArray();
|
||||
String activityManagerId = activityManagerArray.getJSONObject(i).getString("id");
|
||||
log.error("activityManagerId:{}",activityManagerId);
|
||||
|
||||
if(StringUtils.isNotBlank(activityManagerId)){
|
||||
String bodyData = performance2BeiSenUtil.getAssessmentItemCount(token,page,capacity,activityManagerId);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("paging")){
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
itemTotal = pagingJson.getInteger("total");
|
||||
}
|
||||
if(dataObject.containsKey("items")){
|
||||
itemsArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("itemTotal:{}",itemTotal);
|
||||
if(itemTotal <= Integer.valueOf(capacity)){
|
||||
assessmentItemArray = itemsArray;
|
||||
}else{
|
||||
assessmentItemArray.addAll(itemsArray);
|
||||
int pageCount = (int)Math.floor(itemTotal / Integer.valueOf(capacity));
|
||||
for(int k = 1; k < pageCount; k++){
|
||||
log.error("K:{}",k);
|
||||
JSONArray itemArray = performance2BeiSenUtil.queryAssessmentItem(token,String.valueOf(k),capacity,activityManagerId);
|
||||
log.error("itemArray:{}",itemArray.size());
|
||||
assessmentItemArray.addAll(itemArray);
|
||||
}
|
||||
}
|
||||
log.error("JSONArray:{}",JSONArray.toJSONString(assessmentItemArray));
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param activityManagerArray
|
||||
* @param token
|
||||
*/
|
||||
public JSONArray queryAssessment(JSONArray activityManagerArray,String token){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
for(int i = 0; i < activityManagerArray.size(); i++) {
|
||||
String activityManagerId = activityManagerArray.getJSONObject(i).getString("id");
|
||||
log.error("activityManagerId:{}",activityManagerId);
|
||||
if (StringUtils.isNotBlank(activityManagerId)) {
|
||||
JSONArray itemsArray = performance2BeiSenUtil.queryAssessment(token,activityManagerId);
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,347 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.FormFieldDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.HrmDepartmentDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.EbuilderOperateUtils;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Esb2BeiSenAssessmentUtil;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.Token2BeiSenUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2BeisenPerformanceCronJobNew")
|
||||
public class Esb2BeisenPerformanceCronJobNew implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeisenPerformanceCronJobNew.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
@Autowired
|
||||
Esb2BeiSenAssessmentUtil esb2BeiSenAssessmentUtil;
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
HrmDepartmentDao hrmDepartmentDao;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2BeisenPerformanceCronJobNew start");
|
||||
int capacity = Integer.valueOf(String.valueOf(params.get("capacity")));
|
||||
String modifiedAfter = String.valueOf(params.get("modifiedAfter"));
|
||||
String modifiedBefore = String.valueOf(params.get("modifiedBefore"));
|
||||
|
||||
int page = 1;
|
||||
if(params.containsKey("page")){
|
||||
page = Integer.valueOf(String.valueOf(params.get("page")));
|
||||
}
|
||||
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
// String activityManagerUrl = "/PerformanceCloudOpen/api/v5/ActivityManager/GetOrgActivityManagers";
|
||||
// String assessmentItemUrl = "/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItemCount";
|
||||
// String assessmentUrl = "/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds";
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("khnf");
|
||||
fieldList.add("khzq");
|
||||
fieldList.add("gh");
|
||||
fieldList.add("mc");
|
||||
fieldList.add("yx");
|
||||
fieldList.add("bm");
|
||||
fieldList.add("jxxbmmc");
|
||||
fieldList.add("jxhdmc");
|
||||
fieldList.add("zzdf");
|
||||
fieldList.add("jxxs");
|
||||
fieldList.add("bkhr");
|
||||
fieldList.add("khzqlx");
|
||||
fieldList.add("jxxs");
|
||||
|
||||
|
||||
|
||||
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
JSONArray assessmentArray = getAssessmentArray(token,page, capacity, modifiedAfter, modifiedBefore);
|
||||
log.error("assessmentArray:"+assessmentArray.size());
|
||||
// if(StringUtils.isNotBlank(token)){
|
||||
// int total = 0;
|
||||
// JSONArray itemArray = new JSONArray();
|
||||
// String bodyData = esb2BeiSenAssessmentUtil.getAssessmentsByFilters(token, page, capacity, modifiedAfter, modifiedBefore);
|
||||
// if(StringUtils.isNotBlank(bodyData)){
|
||||
// JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
// if(bodyJson.containsKey("code")){
|
||||
// JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
// if(dataObject.containsKey("paging")){
|
||||
// JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
// total = pagingJson.getInteger("total");
|
||||
// }
|
||||
// if(dataObject.containsKey("items")){
|
||||
// itemArray = dataObject.getJSONArray("items");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// log.error("itemArray:"+itemArray.size());
|
||||
//
|
||||
// if(total <= capacity){
|
||||
// assessmentArray.addAll(itemArray) ;
|
||||
// }else{
|
||||
// assessmentArray.addAll(itemArray);
|
||||
// int pageCount = (int)Math.floor(total/(capacity*1.0));
|
||||
// log.error("pageCount:"+pageCount);
|
||||
// for(int i = 1; i < pageCount; i++){
|
||||
// int page2 = i+1;
|
||||
// JSONArray itemArray2 = esb2BeiSenAssessmentUtil.queryAssessmentsByPage(token,page2,capacity,modifiedAfter, modifiedBefore);
|
||||
// assessmentArray.add(itemArray2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
int effectiveTotal = 0;
|
||||
int failTotal = 0;
|
||||
|
||||
if(assessmentArray.size() > 0){
|
||||
JSONArray dataArray = convertAssessmentList(assessmentArray);
|
||||
log.error("dataArray:"+dataArray.size());
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
Map<String, Object> fieldMap = formFieldDao.queryFromTableField(Constants.assessmentFormTable,fieldList);
|
||||
for(int i=0;i<dataArray.size();i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
log.error("dataJson2:{}",dataJson.toJSONString());
|
||||
if(dataJson.containsKey("bkhr") && StringUtils.isNotBlank(dataJson.getString("bkhr"))){
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataJson.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataJson.getString(fieldList.get(n));
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
effectiveTotal++;
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
datas.add(ebDataReqDto);
|
||||
}else{
|
||||
failTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
log.error("datas:{}",datas.size());
|
||||
|
||||
Map<String,Object> recordMap = formFieldDao.queryTableFormId(Constants.assessmentFormTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
EBDataChangeResult ebDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(datas,formId,appId);
|
||||
boolean isTrue = ebDataChangeResult.getStatus();
|
||||
log.error("isTrue:{}",isTrue);
|
||||
if(isTrue){
|
||||
ebList = ebDataChangeResult.getDataIds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.error("ebList:{}", JSON.toJSONString(ebList));
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","同步成功");
|
||||
actionMap.put("total",assessmentArray.size());
|
||||
actionMap.put("effectiveTotal",effectiveTotal);
|
||||
actionMap.put("failTotal",failTotal);
|
||||
actionMap.put("ebTotal",ebList.size());
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param modifiedAfter
|
||||
* @param modifiedBefore
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getAssessmentArray(String token,int page, int capacity, String modifiedAfter, String modifiedBefore) {
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
int total = 0;
|
||||
JSONArray itemArray = new JSONArray();
|
||||
String bodyData = esb2BeiSenAssessmentUtil.getAssessmentsByFilters(token, page, capacity, modifiedAfter, modifiedBefore);
|
||||
if (StringUtils.isNotBlank(bodyData)) {
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if (bodyJson.containsKey("code")) {
|
||||
JSONObject dataObject = bodyJson.getJSONObject("data");
|
||||
if (dataObject.containsKey("paging")) {
|
||||
JSONObject pagingJson = dataObject.getJSONObject("paging");
|
||||
total = pagingJson.getInteger("total");
|
||||
}
|
||||
if (dataObject.containsKey("items")) {
|
||||
itemArray = dataObject.getJSONArray("items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.error("itemArray:" + itemArray.size());
|
||||
|
||||
if (total <= capacity) {
|
||||
assessmentArray.addAll(itemArray);
|
||||
} else {
|
||||
assessmentArray.addAll(itemArray);
|
||||
int pageCount = (int) Math.floor(total / (capacity * 1.0));
|
||||
log.error("pageCount:" + pageCount);
|
||||
for (int i = 1; i < pageCount; i++) {
|
||||
int page2 = i + 1;
|
||||
JSONArray itemArray2 = esb2BeiSenAssessmentUtil.queryAssessmentsByPage(token, page2, capacity, modifiedAfter, modifiedBefore);
|
||||
assessmentArray.add(itemArray2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param assessmentArray
|
||||
* @return
|
||||
*/
|
||||
public JSONArray convertAssessmentList(JSONArray assessmentArray) {
|
||||
|
||||
JSONArray dataArray = new JSONArray();
|
||||
Map<String,Object> departmentMap = hrmDepartmentDao.queryDepartmentData();
|
||||
Map<String,Object> employeeMap = hrmDepartmentDao.queryEmployeeData();
|
||||
log.error("departmentMap:"+departmentMap.size());
|
||||
log.error("employeeMap:"+employeeMap.size());
|
||||
|
||||
|
||||
for(int i=0;i<assessmentArray.size();i++) {
|
||||
JSONObject assessmentJson = assessmentArray.getJSONObject(i);
|
||||
String id = assessmentJson.getString("id");
|
||||
JSONArray fieldDatas = assessmentJson.getJSONArray("fieldDatas");
|
||||
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("bsjxid",id);
|
||||
|
||||
|
||||
|
||||
for(int n=0;n<fieldDatas.size();n++){
|
||||
JSONObject fieldDataJson = fieldDatas.getJSONObject(n);
|
||||
log.error("fieldDataJson:{}",fieldDataJson.toJSONString());
|
||||
|
||||
String name = fieldDataJson.getString("name");
|
||||
String value = fieldDataJson.getString("value");
|
||||
String text = fieldDataJson.getString("text");
|
||||
|
||||
if("ActivityManagerId".equals(name)){
|
||||
dataJson.put("jxhdmc",text);
|
||||
}
|
||||
|
||||
// if("Employee".equals(name)){
|
||||
// dataJson.put("jxhdmc",value);
|
||||
// }
|
||||
// if("DeptId".equals(name)){
|
||||
// dataJson.put("jxhdmc",value);
|
||||
// }
|
||||
|
||||
if("Year".equals(name)){
|
||||
dataJson.put("khnf",value);
|
||||
}
|
||||
if("Period".equals(name)){
|
||||
dataJson.put("khzq",value);
|
||||
|
||||
if("-1".equals(value)){
|
||||
dataJson.put("khzqlx","年度考核");
|
||||
}else if("1".equals(value) || "2".equals(value)
|
||||
|| "3".equals(value)
|
||||
|| "4".equals(value)
|
||||
|| "5".equals(value)
|
||||
|| "6".equals(value)
|
||||
|| "7".equals(value)
|
||||
|| "8".equals(value)
|
||||
|| "9".equals(value)
|
||||
|| "10".equals(value)
|
||||
|| "11".equals(value)
|
||||
|| "12".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","月度考核");
|
||||
}else if("31".equals(value) || "22".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","半年度考核");
|
||||
}else if("21".equals(value) || "22".equals(value) || "23".equals(value) || "24".equals(value)
|
||||
){
|
||||
dataJson.put("khzqlx","季度考核");
|
||||
}
|
||||
}
|
||||
|
||||
if("Name".equals(name)){
|
||||
dataJson.put("mc",value);
|
||||
}
|
||||
|
||||
if("Email".equals(name)){
|
||||
dataJson.put("yx",value);
|
||||
}
|
||||
|
||||
if("StaffCode".equals(name)){
|
||||
dataJson.put("gh",value);
|
||||
log.error("gh:{}",value);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(employeeMap.containsKey(value)){
|
||||
String employeeid = String.valueOf(employeeMap.get(value));
|
||||
log.error("employeeid:{}",employeeid);
|
||||
dataJson.put("bkhr",employeeid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if("StaffDep".equals(name)){
|
||||
dataJson.put("jxxbmmc",text);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(departmentMap.containsKey(value)){
|
||||
String departmentid = String.valueOf(departmentMap.get(value));
|
||||
dataJson.put("bm",departmentid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if("FinalScore".equals(name)){
|
||||
dataJson.put("zzdf",value);
|
||||
}
|
||||
|
||||
if("TotalScoreRuleIdLookup".equals(name)){
|
||||
dataJson.put("jxxs",text);
|
||||
}
|
||||
}
|
||||
dataArray.add(dataJson);
|
||||
log.error("dataJson:{}",dataJson.toJSONString());
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.module;
|
||||
|
||||
/**
|
||||
* 缓存moduleKey
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
|
||||
public class BeisenTokenModuleKey {
|
||||
//datacenter
|
||||
public final static String BENSENTOKEN_DATACENTER = "BENSENTOKEN_DATACENTER";
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface ConversionResignService {
|
||||
|
||||
Map<String,Object> resignConversion(Map<String,Object> paraMap);
|
||||
|
||||
Map<String,Object> resignConversion2(Map<String,Object> paraMap);
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.service.impl;
|
||||
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.weaver.seconddev.chapanda.beisen.dao.ConversionResignDao;
|
||||
import com.weaver.seconddev.chapanda.beisen.service.ConversionResignService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class ConversionResignServiceImpl implements ConversionResignService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConversionResignServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ConversionResignDao conversionResignDao;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> resignConversion(Map<String, Object> paraMap) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String conversionDay = "";
|
||||
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Long employeeId = Long.valueOf(String.valueOf(paraMap.get("employeeId")));
|
||||
String lzrq = (String) paraMap.get("lzrq");
|
||||
log.error("employeeId:"+employeeId);
|
||||
log.error("lzrq:{}",lzrq);
|
||||
|
||||
String hiredate = "";
|
||||
if(employeeId > 0){
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
hiredate = sdf.format(simpleEmployee.getHiredate());
|
||||
}
|
||||
log.error("hiredate:{}",hiredate);
|
||||
|
||||
|
||||
dataMap.put("employeeid",employeeId);
|
||||
dataMap.put("lzrq",lzrq);
|
||||
dataMap.put("rzrq",hiredate);
|
||||
|
||||
if(StringUtils.isNotBlank(lzrq) && StringUtils.isNotBlank(hiredate)){
|
||||
String rznf = hiredate.substring(0,4);
|
||||
String lznf = lzrq.substring(0,4);
|
||||
|
||||
log.error("rznf:"+rznf);
|
||||
log.error("lznf:"+lznf);
|
||||
|
||||
if(StringUtils.isNotBlank(rznf) && StringUtils.isNotBlank(lznf) ){
|
||||
double annualBase = conversionResignDao.queryEmployeeAnnualLeave(String.valueOf(employeeId),lznf);
|
||||
|
||||
log.error("annualBase:"+annualBase);
|
||||
|
||||
dataMap.put("annualBase",annualBase+"");
|
||||
if(rznf.equals(lznf)){
|
||||
LocalDate rzDate = LocalDate.parse(hiredate, formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(lzDate, rzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}else{
|
||||
LocalDate rzDate = LocalDate.parse(lznf+"-01-01", formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(lzDate, rzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap.put("days",conversionDay);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> resignConversion2(Map<String, Object> paraMap) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String conversionDay = "";
|
||||
|
||||
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Long employeeId = Long.valueOf(String.valueOf(paraMap.get("employeeId")));
|
||||
String lzrq = (String) paraMap.get("lzrq");
|
||||
log.error("employeeId:"+employeeId);
|
||||
log.error("lzrq:"+lzrq);
|
||||
|
||||
String hiredate = "";
|
||||
if(employeeId > 0){
|
||||
hiredate = conversionResignDao.queryEmployeeById(String.valueOf(employeeId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(hiredate)){
|
||||
hiredate = hiredate.substring(0,10);
|
||||
}
|
||||
log.error("hiredate:"+hiredate);
|
||||
|
||||
dataMap.put("employeeid",employeeId);
|
||||
dataMap.put("lzrq",lzrq);
|
||||
dataMap.put("rzrq",hiredate);
|
||||
|
||||
if(StringUtils.isNotBlank(lzrq) && StringUtils.isNotBlank(hiredate)){
|
||||
|
||||
String rznf = hiredate.substring(0,4);
|
||||
String lznf = lzrq.substring(0,4);
|
||||
|
||||
log.error("rznf:"+rznf);
|
||||
log.error("lznf:"+lznf);
|
||||
|
||||
if(StringUtils.isNotBlank(rznf) && StringUtils.isNotBlank(lznf) ){
|
||||
double annualBase = conversionResignDao.queryEmployeeAnnualLeave(String.valueOf(employeeId),lznf);
|
||||
|
||||
log.error("annualBase:"+annualBase);
|
||||
|
||||
dataMap.put("annualBase",annualBase+"");
|
||||
if(rznf.equals(lznf)){
|
||||
LocalDate rzDate = LocalDate.parse(hiredate, formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(rzDate,lzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}else{
|
||||
LocalDate rzDate = LocalDate.parse(lznf+"-01-01", formatter);
|
||||
LocalDate lzDate = LocalDate.parse(lzrq, formatter);
|
||||
long workDays = ChronoUnit.DAYS.between(rzDate,lzDate);
|
||||
dataMap.put("workdays",workDays+"");
|
||||
if(annualBase !=0){
|
||||
conversionDay = new BigDecimal(Double.toString((workDays/365.0)*annualBase)).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap.put("days",conversionDay);
|
||||
return dataMap;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffPositionDto;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenDepartmentInfoByOriginalIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenDepartmentInfoByOriginalIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenStaffDto getBeisenDeptDataByOriginalId(String staffcode){
|
||||
BeisenStaffDto beisenStaffDto = new BeisenStaffDto();
|
||||
if(StringUtils.isEmpty(staffcode)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryUserInfoByStaffCode(token,staffcode);
|
||||
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
if("200".equals(code)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
|
||||
if(itemObject.containsKey("staffDto")){
|
||||
JSONObject staffDto = itemObject.getJSONObject("staffDto");
|
||||
beisenStaffDto.setDepartmentId(staffDto.getString("departmentId"));
|
||||
beisenStaffDto.setDepartmentName(staffDto.getString("departmentName"));
|
||||
String employedDate = staffDto.getString("employedDate");
|
||||
|
||||
if(!"null".equals(employedDate) && employedDate !=null ){
|
||||
if(employedDate.contains("T")){
|
||||
employedDate = employedDate.substring(0,employedDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setEmployedDate(employedDate);
|
||||
|
||||
beisenStaffDto.setJobCode(staffDto.getString("jobCode"));
|
||||
beisenStaffDto.setPositionName(staffDto.getString("positionName"));
|
||||
beisenStaffDto.setLineManagerId(staffDto.getString("lineManagerId"));
|
||||
beisenStaffDto.setStaffCode(staffDto.getString("staffCode"));
|
||||
beisenStaffDto.setStaffStatus(staffDto.getString("staffStatus"));
|
||||
beisenStaffDto.setIsDelete(staffDto.getString("isDelete"));
|
||||
String useridStr = staffDto.getString("userId");
|
||||
int userid = -1 ;
|
||||
if(StringUtils.isNotBlank(useridStr)){
|
||||
try{
|
||||
userid = Integer.valueOf(useridStr);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
beisenStaffDto.setUserId(userid);
|
||||
|
||||
beisenStaffDto.setTenantId(staffDto.getString("tenantId"));
|
||||
beisenStaffDto.setEmail(staffDto.getString("email"));
|
||||
beisenStaffDto.setUserType(staffDto.getString("userType"));
|
||||
beisenStaffDto.setUserStatus(staffDto.getString("userStatus"));
|
||||
beisenStaffDto.setOrigin(staffDto.getString("origin"));
|
||||
beisenStaffDto.setOriginalId(staffDto.getString("originalId"));
|
||||
beisenStaffDto.setName(staffDto.getString("name"));
|
||||
beisenStaffDto.setEnglishName(staffDto.getString("englishName"));
|
||||
beisenStaffDto.setSex(staffDto.getString("sex"));
|
||||
String birthday = staffDto.getString("birthday");
|
||||
|
||||
if(!"null".equals(birthday) && birthday !=null ){
|
||||
if(birthday.contains("T")){
|
||||
birthday = birthday.substring(0,birthday.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
beisenStaffDto.setBirthday(birthday);
|
||||
beisenStaffDto.setMobile(staffDto.getString("mobile"));
|
||||
beisenStaffDto.setIdCardType(staffDto.getString("idCardType"));
|
||||
|
||||
String graduateDate = staffDto.getString("graduateDate");
|
||||
if(!"null".equals(graduateDate) && graduateDate !=null ){
|
||||
if(graduateDate.contains("T")){
|
||||
graduateDate = graduateDate.substring(0,graduateDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
beisenStaffDto.setGraduateDate(graduateDate);
|
||||
|
||||
beisenStaffDto.setNativePlace(staffDto.getString("nativePlace"));
|
||||
String beganWorkDate = staffDto.getString("beganWorkDate");
|
||||
if(!"null".equals(beganWorkDate) && beganWorkDate !=null ){
|
||||
if(beganWorkDate.contains("T")){
|
||||
beganWorkDate = beganWorkDate.substring(0,beganWorkDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setBeganWorkDate(beganWorkDate);
|
||||
beisenStaffDto.setGraduateFrom(staffDto.getString("graduateFrom"));
|
||||
beisenStaffDto.setMajor(staffDto.getString("major"));
|
||||
beisenStaffDto.setPositionCategory(staffDto.getString("positionCategory"));
|
||||
}
|
||||
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto = new BeisenStaffDepartmentDto();
|
||||
if(itemObject.containsKey("departmentDto")){
|
||||
JSONObject departmentDto = itemObject.getJSONObject("departmentDto");
|
||||
beisenStaffDepartmentDto.setId(departmentDto.getString("id"));
|
||||
beisenStaffDepartmentDto.setName(departmentDto.getString("name"));
|
||||
beisenStaffDepartmentDto.setCode(departmentDto.getString("code"));
|
||||
beisenStaffDepartmentDto.setAbbreviation(departmentDto.getString("abbreviation"));
|
||||
beisenStaffDepartmentDto.setParentId(departmentDto.getString("parentId"));
|
||||
beisenStaffDepartmentDto.setLevel(departmentDto.getString("level"));
|
||||
beisenStaffDepartmentDto.setStatus(departmentDto.getString("status"));
|
||||
beisenStaffDepartmentDto.setIsDelete(departmentDto.getString("isDelete"));
|
||||
beisenStaffDepartmentDto.setOriginalId(departmentDto.getString("originalId"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffDepartmentDto(beisenStaffDepartmentDto);
|
||||
|
||||
BeisenStaffPositionDto beisenStaffPositionDto = new BeisenStaffPositionDto();
|
||||
if(itemObject.containsKey("positionDto")){
|
||||
JSONObject positionDto = itemObject.getJSONObject("positionDto");
|
||||
|
||||
beisenStaffPositionDto.setId(positionDto.getString("id"));
|
||||
beisenStaffPositionDto.setName(positionDto.getString("name"));
|
||||
beisenStaffPositionDto.setCode(positionDto.getString("code"));
|
||||
beisenStaffPositionDto.setStatus(positionDto.getString("status"));
|
||||
beisenStaffPositionDto.setIsDelete(positionDto.getString("isDelete"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffPositionDto(beisenStaffPositionDto);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenStaffDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryUserInfoByStaffCode(String token,String staffcode){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.userInfoUrl+"?staffCode="+staffcode)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
log.error("msg:"+response.body().string());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenDepartmentDto;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenDeptInfoByOriginalIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenDeptInfoByOriginalIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenDepartmentDto getBeisenDeptDataByOriginalId(String originalId){
|
||||
BeisenDepartmentDto beisenDepartmentDto = new BeisenDepartmentDto();
|
||||
if(StringUtils.isNotEmpty(originalId)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryDeptDataByOriginalId(token,originalId);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
log.error("code:{}",code);
|
||||
if("200".equals(code)){
|
||||
if(bodyJson.containsKey("items")){
|
||||
String items = bodyJson.getString("items");
|
||||
if(!"[]".equals(items)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
if(itemsArray.size() > 0){
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
log.error("itemsArray:{}",itemsArray.size());
|
||||
log.error("itemObject:{}",itemObject.toJSONString());
|
||||
|
||||
log.error("orgId:{}",itemObject.getString("orgId"));
|
||||
int orgId = -1;
|
||||
String orgIdStr = itemObject.getString("orgId");
|
||||
if(StringUtils.isNotBlank(orgIdStr)){
|
||||
orgId = Integer.valueOf(orgIdStr);
|
||||
}
|
||||
beisenDepartmentDto.setOrgId(orgId);
|
||||
|
||||
beisenDepartmentDto.setName(itemObject.getString("name"));
|
||||
beisenDepartmentDto.setCode(itemObject.getString("code"));
|
||||
|
||||
beisenDepartmentDto.setAbbreviation(itemObject.getString("abbreviation"));
|
||||
beisenDepartmentDto.setParentOriginalId(itemObject.getString("parentOriginalId"));
|
||||
beisenDepartmentDto.setOriginalId(itemObject.getString("originalId"));
|
||||
beisenDepartmentDto.setOrderId(itemObject.getString("orderId"));
|
||||
beisenDepartmentDto.setStatus(itemObject.getString("status"));
|
||||
beisenDepartmentDto.setIsDelete(itemObject.getString("isDelete"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenDepartmentDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryDeptDataByOriginalId(String token,String originalId){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.deppartmentUrl+"?originalId="+originalId)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
log.error("bodyData:{}",bodyData);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDepartmentDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffDto;
|
||||
import com.weaver.seconddev.chapanda.beisen.entity.BeisenStaffPositionDto;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class BeisenStaffInfoByStaffCodeUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BeisenStaffInfoByStaffCodeUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public BeisenStaffDto getBeisenStaffInfoByStaffCode(String staffcode){
|
||||
BeisenStaffDto beisenStaffDto = new BeisenStaffDto();
|
||||
if(StringUtils.isNotEmpty(staffcode)){
|
||||
String token = token2BeiSenUtil.getToken();
|
||||
log.error("token:{}",token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String bodyData = queryUserInfoByStaffCode(token,staffcode);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject bodyJson = JSONObject.parseObject(bodyData);
|
||||
if(bodyJson.containsKey("code")){
|
||||
String code = bodyJson.getString("code");
|
||||
log.error("code:{}",code);
|
||||
if("200".equals(code)){
|
||||
String items = bodyJson.getString("items");
|
||||
if(!"[]".equals(items)){
|
||||
JSONArray itemsArray = bodyJson.getJSONArray("items");
|
||||
log.error("itemsArray:{}",itemsArray.size());
|
||||
if(itemsArray.size() > 0){
|
||||
|
||||
JSONObject itemObject = itemsArray.getJSONObject(0);
|
||||
log.error("itemObject:{}",itemObject.size());
|
||||
|
||||
if(itemObject.containsKey("staffDto")){
|
||||
JSONObject staffDto = itemObject.getJSONObject("staffDto");
|
||||
log.error("staffDto:{}",staffDto.size());
|
||||
beisenStaffDto.setDepartmentId(staffDto.getString("departmentId"));
|
||||
beisenStaffDto.setDepartmentName(staffDto.getString("departmentName"));
|
||||
String employedDate = staffDto.getString("employedDate");
|
||||
log.error("employedDate:{}",employedDate);
|
||||
if(!"null".equals(employedDate) && employedDate !=null ){
|
||||
if(employedDate.contains("T")){
|
||||
employedDate = employedDate.substring(0,employedDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
log.error("employedDate:{}",employedDate);
|
||||
|
||||
beisenStaffDto.setEmployedDate(employedDate);
|
||||
|
||||
beisenStaffDto.setJobCode(staffDto.getString("jobCode"));
|
||||
beisenStaffDto.setPositionName(staffDto.getString("positionName"));
|
||||
beisenStaffDto.setLineManagerId(staffDto.getString("lineManagerId"));
|
||||
beisenStaffDto.setStaffCode(staffDto.getString("staffCode"));
|
||||
beisenStaffDto.setStaffStatus(staffDto.getString("staffStatus"));
|
||||
beisenStaffDto.setIsDelete(staffDto.getString("isDelete"));
|
||||
String useridStr = staffDto.getString("userId");
|
||||
int userid = -1 ;
|
||||
if(StringUtils.isNotBlank(useridStr)){
|
||||
try{
|
||||
userid = Integer.valueOf(useridStr);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
beisenStaffDto.setUserId(userid);
|
||||
|
||||
beisenStaffDto.setTenantId(staffDto.getString("tenantId"));
|
||||
beisenStaffDto.setEmail(staffDto.getString("email"));
|
||||
beisenStaffDto.setUserType(staffDto.getString("userType"));
|
||||
beisenStaffDto.setUserStatus(staffDto.getString("userStatus"));
|
||||
beisenStaffDto.setOrigin(staffDto.getString("origin"));
|
||||
beisenStaffDto.setOriginalId(staffDto.getString("originalId"));
|
||||
beisenStaffDto.setName(staffDto.getString("name"));
|
||||
beisenStaffDto.setEnglishName(staffDto.getString("englishName"));
|
||||
beisenStaffDto.setSex(staffDto.getString("sex"));
|
||||
String birthday = staffDto.getString("birthday");
|
||||
|
||||
if(!"null".equals(birthday) && birthday !=null ){
|
||||
if(birthday.contains("T")){
|
||||
birthday = birthday.substring(0,birthday.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
beisenStaffDto.setBirthday(birthday);
|
||||
beisenStaffDto.setMobile(staffDto.getString("mobile"));
|
||||
beisenStaffDto.setIdCardType(staffDto.getString("idCardType"));
|
||||
|
||||
String graduateDate = staffDto.getString("graduateDate");
|
||||
|
||||
if(!"null".equals(graduateDate) && graduateDate !=null ){
|
||||
if(graduateDate.contains("T")){
|
||||
graduateDate = graduateDate.substring(0,graduateDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.error("graduateDate:{}",graduateDate);
|
||||
beisenStaffDto.setGraduateDate(graduateDate);
|
||||
|
||||
beisenStaffDto.setNativePlace(staffDto.getString("nativePlace"));
|
||||
String beganWorkDate = staffDto.getString("beganWorkDate");
|
||||
|
||||
if(!"null".equals(beganWorkDate) && beganWorkDate !=null ){
|
||||
if(beganWorkDate.contains("T")){
|
||||
beganWorkDate = beganWorkDate.substring(0,beganWorkDate.indexOf("T"));
|
||||
}
|
||||
}
|
||||
|
||||
log.error("graduateDate:{}",graduateDate);
|
||||
beisenStaffDto.setBeganWorkDate(beganWorkDate);
|
||||
beisenStaffDto.setGraduateFrom(staffDto.getString("graduateFrom"));
|
||||
beisenStaffDto.setMajor(staffDto.getString("major"));
|
||||
beisenStaffDto.setPositionCategory(staffDto.getString("positionCategory"));
|
||||
}
|
||||
|
||||
BeisenStaffDepartmentDto beisenStaffDepartmentDto = new BeisenStaffDepartmentDto();
|
||||
if(itemObject.containsKey("departmentDto")){
|
||||
JSONObject departmentDto = itemObject.getJSONObject("departmentDto");
|
||||
beisenStaffDepartmentDto.setId(departmentDto.getString("id"));
|
||||
beisenStaffDepartmentDto.setName(departmentDto.getString("name"));
|
||||
beisenStaffDepartmentDto.setCode(departmentDto.getString("code"));
|
||||
beisenStaffDepartmentDto.setAbbreviation(departmentDto.getString("abbreviation"));
|
||||
beisenStaffDepartmentDto.setParentId(departmentDto.getString("parentId"));
|
||||
beisenStaffDepartmentDto.setLevel(departmentDto.getString("level"));
|
||||
beisenStaffDepartmentDto.setStatus(departmentDto.getString("status"));
|
||||
beisenStaffDepartmentDto.setIsDelete(departmentDto.getString("isDelete"));
|
||||
beisenStaffDepartmentDto.setOriginalId(departmentDto.getString("originalId"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffDepartmentDto(beisenStaffDepartmentDto);
|
||||
|
||||
BeisenStaffPositionDto beisenStaffPositionDto = new BeisenStaffPositionDto();
|
||||
if(itemObject.containsKey("positionDto")){
|
||||
JSONObject positionDto = itemObject.getJSONObject("positionDto");
|
||||
|
||||
beisenStaffPositionDto.setId(positionDto.getString("id"));
|
||||
beisenStaffPositionDto.setName(positionDto.getString("name"));
|
||||
beisenStaffPositionDto.setCode(positionDto.getString("code"));
|
||||
beisenStaffPositionDto.setStatus(positionDto.getString("status"));
|
||||
beisenStaffPositionDto.setIsDelete(positionDto.getString("isDelete"));
|
||||
}
|
||||
beisenStaffDto.setBeisenStaffPositionDto(beisenStaffPositionDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return beisenStaffDto;
|
||||
}
|
||||
|
||||
|
||||
public String queryUserInfoByStaffCode(String token,String staffcode){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.userInfoUrl+"?staffCode="+staffcode)
|
||||
.method("GET", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:"+e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
public class BlackList2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(BlackList2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public String createBlackList4NonSystem(String token,String name,String staffEmail,String blackAddReason,String blackStaffDesc){
|
||||
|
||||
log.error("createBlackList4NonSystem");
|
||||
String objectId = "";
|
||||
|
||||
// 选项名称 选项编码 启用状态
|
||||
//重大违纪 1 启用
|
||||
//诚信问题 2 启用
|
||||
//稳定性差 3 启用
|
||||
//辞职 4 启用
|
||||
//其他 5 启用
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("name",name);
|
||||
dataJson.put("staffEmail",staffEmail);
|
||||
dataJson.put("blackAddReason",blackAddReason);
|
||||
dataJson.put("blackStaffDesc",blackStaffDesc);
|
||||
|
||||
// dataJson.put("name","王芳");
|
||||
// dataJson.put("staffEmail","798989044@qq.com");
|
||||
// dataJson.put("blackAddReason","3");
|
||||
// dataJson.put("blackStaffDesc","做事不认真");
|
||||
|
||||
bodyJson.put("data",dataJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/Create
|
||||
// "{\n \"data\": {\n \"name\": \"测试王芳\",\n \"staffEmail\": \"798989044@qq.com\",\n \"blackAddReason\":\"3\",\n \"blackStaffDesc\":\"做事不认真\"\n }\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+ Constants.createBlackListUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
log.error("code:{}",code);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("objectId")){
|
||||
objectId = dataObject.getString("objectId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
|
||||
log.error("objectId:{}",objectId);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return objectId;
|
||||
}
|
||||
|
||||
|
||||
public String createBlackList4ResignUser(String token,String userID,String lastWorkDate,String blackAddReason,String blackStaffDesc){
|
||||
log.error("createBlackList4ResignUser");
|
||||
String objectId = "";
|
||||
|
||||
// 选项名称 选项编码 启用状态
|
||||
//重大违纪 1 启用
|
||||
//诚信问题 2 启用
|
||||
//稳定性差 3 启用
|
||||
//辞职 4 启用
|
||||
//其他 5 启用
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("userID",userID);
|
||||
dataJson.put("blackListSource","1");
|
||||
dataJson.put("lastWorkDate",lastWorkDate);
|
||||
dataJson.put("blackAddReason",blackAddReason);
|
||||
dataJson.put("blackStaffDesc",blackStaffDesc);
|
||||
|
||||
// dataJson.put("userID","王芳");
|
||||
// dataJson.put("blackListSource","1");
|
||||
// dataJson.put("lastWorkDate","2025-05-30");
|
||||
// dataJson.put("blackAddReason","3");
|
||||
// dataJson.put("blackStaffDesc","做事不认真");
|
||||
|
||||
bodyJson.put("data",dataJson);
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/Create
|
||||
// "{\n \"data\": {\n \"name\": \"测试王芳\",\n \"staffEmail\": \"798989044@qq.com\",\n \"blackAddReason\":\"3\",\n \"blackStaffDesc\":\"做事不认真\"\n }\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.createBlackListUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
System.out.println("code:"+code);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject bodyData = JSONObject.parseObject(msg);
|
||||
if(bodyData.containsKey("code")){
|
||||
String dataCode = bodyData.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = bodyData.getJSONObject("data");
|
||||
if(dataObject.containsKey("objectId")){
|
||||
objectId = dataObject.getString("objectId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/***
|
||||
* 批量删除黑名单
|
||||
* @param token
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
public String batchDeleteBlackList(String token,List<String> idList){
|
||||
|
||||
String msg = "";
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("Ids",idList);
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/BlackList/BatchDelete
|
||||
// "{\n \"Ids\": [\n \"0441166f-468e-425f-9163-4a9d922169e3\"\n ]\n}"
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.deleteBlackListUrl)
|
||||
.method("DELETE", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
if(code == 200 ){
|
||||
msg = response.body().string();
|
||||
}
|
||||
log.error("msg:"+msg);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,366 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class EbuilderOperateUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EbuilderOperateUtils.class);
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
@RpcReference(group = "ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
|
||||
public EBDataChangeResult bacthInsertDbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
log.error("bacthInsertDbForm");
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
// 主表数据参数
|
||||
// Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
// if("uf_yzgl".equals(formTable)){
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(fieldList.get(n).equals("yzzl")){
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, "2"));
|
||||
// }else{
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }else{
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthEditEbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
if (StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)) {
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
/**
|
||||
* 直接通过id更新数据, 即update table set a = '11' where id = 1
|
||||
*/
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 若数据写入后就要从前台看到数据或者立即操作本次写入的数据, 需要调整后置处理为同步 权限处理完成再返回
|
||||
ebDataReqOperation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
// 数据没有找到的时候是否新增数据
|
||||
EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo();
|
||||
ebDataReqOperationInfo.setNeedAdd(true);
|
||||
ebDataReqOperation.setMainData(ebDataReqOperationInfo);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class EbuilderUtils {
|
||||
|
||||
@RpcReference(group="ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
public EBDataChangeResult bacthInsertDbForm(String referrer_id,int points,String talent_id) {
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader("1120080325150089217", Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// 主表数据参数
|
||||
List<EBDataReqDetailDto> mainData1 = new ArrayList<EBDataReqDetailDto>();
|
||||
// 单行文本
|
||||
mainData1.add(new EBDataReqDetailDto("1120080376580644871", referrer_id));
|
||||
mainData1.add(new EBDataReqDetailDto("1120080376580644872", String.valueOf(points)));
|
||||
ebDataReqDto.setMainDatas(mainData1);
|
||||
|
||||
// 明细数据参数
|
||||
Map<Long, List<List<EBDataReqDetailDto>>> detailDatas = new HashMap<>();
|
||||
// 多条明细数据
|
||||
List<List<EBDataReqDetailDto>> subFormDatas = new ArrayList<>();
|
||||
// 单明细数据不同字段值 - 明细数据1
|
||||
List<EBDataReqDetailDto> subFormRowData1 = new ArrayList<>();
|
||||
subFormRowData1.add(new EBDataReqDetailDto("1120167723322155008", talent_id,false));
|
||||
subFormRowData1.add(new EBDataReqDetailDto("1120080728843460609", String.valueOf(points),false));
|
||||
subFormDatas.add(subFormRowData1);
|
||||
detailDatas.put(1120080376580644874L, subFormDatas);
|
||||
ebDataReqDto.setDetailDatas(detailDatas);
|
||||
|
||||
datas.add(ebDataReqDto);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
EBDataChangeResult ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
|
||||
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthAppendEbDetail(String rcid,int points,String mainid) {
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader("1120080325150089217", Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 数据组装
|
||||
List<EBDataReqDto> datas = new ArrayList<>();
|
||||
// 第一个数据项
|
||||
EBDataReqDto ebDataReqDto1 = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainDatas1 = new ArrayList<>();
|
||||
// 主表数据组装
|
||||
mainDatas1.add(new EBDataReqDetailDto("id", mainid, false));
|
||||
ebDataReqDto1.setMainDatas(mainDatas1);
|
||||
|
||||
/****************** 设置明细操作方式 - 不做覆盖 需要追加 ******************/
|
||||
Map<Long, EBDataReqOperationInfo> detailDatas = new HashMap<>();
|
||||
EBDataReqOperationInfo detailOperation = new EBDataReqOperationInfo();
|
||||
detailOperation.setCover(false);
|
||||
detailOperation.setNeedAdd(true);
|
||||
detailDatas.put(1120080376580644874L, detailOperation);
|
||||
ebDataReqOperation.setDetailDatas(detailDatas);
|
||||
|
||||
// 明细行数据组装
|
||||
Map<Long, List<List<EBDataReqDetailDto>>> detailDatas1 = new HashMap<>();
|
||||
List<List<EBDataReqDetailDto>> detailDataList1 = new ArrayList<>();
|
||||
List<EBDataReqDetailDto> detailData1 = new ArrayList<EBDataReqDetailDto>();
|
||||
// 第一个明细表 第一条数据
|
||||
detailData1.add(new EBDataReqDetailDto("1120167723322155008", rcid, false));
|
||||
detailData1.add(new EBDataReqDetailDto("1120080728843460609", String.valueOf(points), false));
|
||||
detailDataList1.add(detailData1);
|
||||
detailDatas1.put(1120080376580644874L, detailDataList1);
|
||||
ebDataReqDto1.setDetailDatas(detailDatas1);
|
||||
datas.add(ebDataReqDto1);
|
||||
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
|
||||
// 设置数据
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
EBDataChangeResult ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2BeiSenAssessmentUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2BeiSenAssessmentUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param modifiedAfter
|
||||
* @param modifiedBefore
|
||||
*/
|
||||
public String getAssessmentsByFilters(String token, int page, int capacity, String modifiedAfter, String modifiedBefore) {
|
||||
String bodyData = "";
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page", page);
|
||||
bodyJson.put("capacity", capacity);
|
||||
bodyJson.put("modifiedAfter", modifiedAfter);
|
||||
bodyJson.put("modifiedBefore", modifiedBefore);
|
||||
log.error("getAssessmentsByFilters:bodyJson:{}", bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentFilterUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}", code);
|
||||
if (code == 200) {
|
||||
bodyData = response.body().string();
|
||||
}
|
||||
|
||||
log.error("bodyData:{}", bodyData);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public JSONArray queryAssessmentsByPage(String token, int page, int capacity, String modifiedAfter, String modifiedBefore){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page", page);
|
||||
bodyJson.put("capacity", capacity);
|
||||
bodyJson.put("modifiedAfter", modifiedAfter);
|
||||
bodyJson.put("modifiedBefore", modifiedBefore);
|
||||
log.error("queryAssessmentsByPage:bodyJson:{}", bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentFilterUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.error("assessmentArray:{}",assessmentArray.size());
|
||||
return assessmentArray;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class JobRequirement2BeisenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(JobRequirement2BeisenUtil.class);
|
||||
|
||||
@Autowired
|
||||
Token2BeiSenUtil token2BeiSenUtil ;
|
||||
|
||||
public String sendJobRequirement(String token,
|
||||
int requirementStatus,
|
||||
int requirementType,
|
||||
String requestname,
|
||||
int beisenCreateBy,
|
||||
String createDate,
|
||||
int requirementCount,
|
||||
String arivalTime,
|
||||
String createByEmail,
|
||||
String dutyUserEmail,
|
||||
int beisenDepartmentId,
|
||||
int salaryType,
|
||||
int category,
|
||||
String educationInfo,
|
||||
String workExperience,
|
||||
int kind,
|
||||
boolean isSecrecy,
|
||||
String originalCode
|
||||
){
|
||||
String data = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
/***
|
||||
* 需求状态
|
||||
* 10 草稿
|
||||
* 20 审批中
|
||||
* 30 审批未通过
|
||||
* 40 进行中
|
||||
* 50 已关闭
|
||||
* 60 已完成
|
||||
* 70 已暂停
|
||||
* 80 审批已终止
|
||||
*
|
||||
*/
|
||||
if(requirementStatus > -1){
|
||||
bodyJson.put("requirementStatus",requirementStatus);
|
||||
}
|
||||
|
||||
/***
|
||||
* 需求类型
|
||||
* 1 新增
|
||||
* 2 顶替
|
||||
* 3 储备
|
||||
*/
|
||||
if(requirementType > -1){
|
||||
bodyJson.put("requirementType",requirementType);
|
||||
}
|
||||
|
||||
|
||||
bodyJson.put("name",requestname);
|
||||
|
||||
if(beisenCreateBy > -1){
|
||||
bodyJson.put("createBy",beisenCreateBy);
|
||||
}
|
||||
|
||||
if(!createDate.contains("T")){
|
||||
createDate = createDate+"T00:00:00";
|
||||
}
|
||||
bodyJson.put("createDate",createDate);
|
||||
|
||||
if(!arivalTime.contains("T")){
|
||||
arivalTime = arivalTime+"T00:00:00";
|
||||
}
|
||||
bodyJson.put("arivalTime",arivalTime);
|
||||
|
||||
bodyJson.put("dutyUserEmail",dutyUserEmail);
|
||||
bodyJson.put("createByEmail",createByEmail);
|
||||
|
||||
if(beisenDepartmentId > -1){
|
||||
bodyJson.put("departmentId",beisenDepartmentId);
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(originalCode)){
|
||||
bodyJson.put("orgCode",originalCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 需求人数
|
||||
*/
|
||||
if(requirementCount > -1){
|
||||
bodyJson.put("requirementCount",requirementCount);
|
||||
}
|
||||
|
||||
// if(salaryType >-1){
|
||||
// bodyJson.put("salaryType",salaryType);
|
||||
// }
|
||||
|
||||
|
||||
/***
|
||||
* 招聘类别
|
||||
* 1 社会招聘
|
||||
* 2 校园招聘
|
||||
* 3 实习生招聘
|
||||
*/
|
||||
|
||||
if(category > -1){
|
||||
bodyJson.put("category",category);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 学历要求
|
||||
* 9 小学
|
||||
* 8 初中
|
||||
* 3 高中
|
||||
* 4 中技(中专/技校/职高)
|
||||
* 5 大专
|
||||
* 1 本科
|
||||
* 2 硕士研究生
|
||||
* 6 MBA
|
||||
* 7 博士研究生
|
||||
* 10 大专及以上
|
||||
* 11 本科及以上
|
||||
* 12 不限
|
||||
*/
|
||||
bodyJson.put("educationInfo",educationInfo);
|
||||
/***
|
||||
* 工作经验
|
||||
* 在读学生
|
||||
* 应届毕业生
|
||||
* 99 在读学生
|
||||
* 98 应届毕业生
|
||||
* 1 1年
|
||||
* 2 2年
|
||||
* 3 3年
|
||||
* 4 4年
|
||||
* 5 5年
|
||||
* 6 6年
|
||||
* 7 7年
|
||||
* 8 8年
|
||||
* 9 9年
|
||||
* 10 10年及以上
|
||||
*/
|
||||
bodyJson.put("workExperience",workExperience);
|
||||
|
||||
/***
|
||||
* 工作性质
|
||||
* 1 全职
|
||||
* 2 兼职
|
||||
* 3 实习
|
||||
* 4 其他
|
||||
*/
|
||||
|
||||
if(kind > -1){
|
||||
bodyJson.put("kind",kind);
|
||||
}
|
||||
|
||||
bodyJson.put("isSecrecy",isSecrecy);
|
||||
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
// RequestBody body = RequestBody.create(mediaType, "{\n \"requirementStatus\":50,\n \"requirementType\":3,\n \"name\":\"测试招聘需求接口\",\n \"departmentId\":2335561,\n \"createBy\":402189433,\n \"createDate\":\"2025-07-01T10:05:45\",\n \"arivalTime\":\"2025-08-01T10:00:00\",\n \"dutyUserEmail\":\"yemintest@chabaidao.com\",\n \"createByEmail\":\"yemintest@chabaidao.com\"\n}");
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.jobRequirementUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String bodyData = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("bodyData:{}",bodyData);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(bodyData)){
|
||||
JSONObject dataJson = JSONObject.parseObject(bodyData);
|
||||
if(dataJson.containsKey("code")){
|
||||
String dataCode = dataJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
data = dataJson.getString("data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("bodyData:"+bodyData);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Offer2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Offer2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public JSONArray queryOfferByDateTime(String token,String startDate, String startTime, String endDate, String endTime){
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
JSONArray offerArray = new JSONArray();
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+ Constants.offerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
offerArray.addAll(dataArray);
|
||||
String scrollId = returnJson.getString("scrollId");
|
||||
if(StringUtils.isNotBlank(scrollId)){
|
||||
queryOfferByscrollId(token, startDate, startTime, endDate, endTime,offerArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return offerArray;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @param offerArray
|
||||
*/
|
||||
public void queryOfferByscrollId(String token, String startDate, String startTime, String endDate, String endTime,JSONArray offerArray){
|
||||
|
||||
// https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
bodyJson.put("timeWindowQueryType","1");
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.offerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
offerArray.addAll(dataArray);
|
||||
String scrollId = returnJson.getString("scrollId");
|
||||
if(StringUtils.isNotBlank(scrollId)){
|
||||
queryOfferByscrollId(token, startDate, startTime, endDate, endTime,dataArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,309 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Performance2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Performance2BeiSenUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param page
|
||||
* @param capacity
|
||||
* @param year
|
||||
* @param period
|
||||
*/
|
||||
public String getActivityManagerCount(String token,String page,String capacity,String year,String period){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("year",year);
|
||||
bodyJson.put("period",period);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"year\": 2024,\n \"period\": 8\n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/ActivityManager/GetActivityManagers"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.activityManagerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return bodyData ;
|
||||
}
|
||||
|
||||
|
||||
public JSONArray queryActivityManager(String token,String page,String capacity,String year,String period){
|
||||
JSONArray performanceArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("year",year);
|
||||
bodyJson.put("period",period);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"year\": 2024,\n \"period\": 8\n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/ActivityManager/GetActivityManagers"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.activityManagerUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "text/plain")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
performanceArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return performanceArray;
|
||||
}
|
||||
|
||||
|
||||
public String getAssessmentItemCount(String token,String page,String capacity,String activityManagerId){
|
||||
String bodyData = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("activityManagerId",activityManagerId);
|
||||
JSONObject sortJson = new JSONObject();
|
||||
sortJson.put("Name",-1);
|
||||
bodyJson.put("sort",sortJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
// "{\n \"page\": 0,\n \"capacity\": 10,\n \"sort\": {\n \"Name\": -1\n },\n \"activityManagerId\": \"62822578-2bba-4980-9826-00689705c58d\"\n \n}"
|
||||
// "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/AssessmentItem/GetAssessmentItems"
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
bodyData = response.body().string();
|
||||
}else{
|
||||
String msg = response.body().string();
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public JSONArray queryAssessmentItem(String token,String page,String capacity,String activityManagerId){
|
||||
JSONArray assessmentItemArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("page",page);
|
||||
bodyJson.put("capacity",capacity);
|
||||
bodyJson.put("activityManagerId",activityManagerId);
|
||||
JSONObject sortJson = new JSONObject();
|
||||
sortJson.put("Name",-1);
|
||||
bodyJson.put("sort",sortJson);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentItemArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return assessmentItemArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public String getAssessmentCount(String token,String activityManagerId){
|
||||
// String bodyData = "";
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// String[] columns = new String[]{"_id","Name","ModifiedTime","ActivityManagerId"};
|
||||
// bodyJson.put("columns",columns);
|
||||
// String[] assessmentIds = new String[]{activityManagerId};
|
||||
// bodyJson.put("assessmentIds",assessmentIds);
|
||||
//
|
||||
// // "{\n \"columns\":[\n \"_id\",\n \"Name\",\n \"ModifiedTime\",\n \"ActivityManagerId\"\n ],\n \"assessmentIds\" : [\"2e0c22bc-7295-4993-961b-822053f70563\"]\n}"
|
||||
// // "https://openapi.italent.cn/PerformanceCloudOpen/api/v5/Assessment/GetAssessmentsByIds"
|
||||
//
|
||||
// RequestBody body = RequestBody.create(mediaType,bodyJson.toJSONString());
|
||||
// Request request = new Request.Builder()
|
||||
// .url(Constants.beishenHost+Constants.assessmentUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .build();
|
||||
// try {
|
||||
// Response response = client.newCall(request).execute();
|
||||
// int code = response.code();
|
||||
// log.error("code:{}",code);
|
||||
// if(code == 200){
|
||||
// bodyData = response.body().string();
|
||||
// }else{
|
||||
// String msg = response.body().string();
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return bodyData;
|
||||
// }
|
||||
|
||||
public JSONArray queryAssessment(String token,String activityManagerId){
|
||||
JSONArray assessmentArray = new JSONArray();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
String[] columns = new String[]{"_id","Name","ModifiedTime","ActivityManagerId"};
|
||||
bodyJson.put("columns",columns);
|
||||
String[] assessmentIds = new String[]{activityManagerId};
|
||||
bodyJson.put("assessmentIds",assessmentIds);
|
||||
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.beishenHost+Constants.assessmentItemUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONObject dataObject = returnJson.getJSONObject("data");
|
||||
if(dataObject.containsKey("items")){
|
||||
JSONArray itemsArray = dataObject.getJSONArray("items");
|
||||
assessmentArray.addAll(itemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return assessmentArray;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,242 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.beisen.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.seconddev.chapanda.beisen.cache.BeisenTokenCacheKey;
|
||||
import com.weaver.seconddev.chapanda.beisen.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.beisen.module.BeisenTokenModuleKey;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
|
||||
@Component
|
||||
public class Token2BeiSenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Token2BeiSenUtil.class);
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
public int earlySecond = 120;
|
||||
|
||||
/***
|
||||
* 获取token
|
||||
*/
|
||||
public String getToken(){
|
||||
|
||||
String token = (String) baseCache.get(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, BeisenTokenCacheKey.BEISEN_TOKEN);
|
||||
log.error("token:{}",token);
|
||||
try{
|
||||
if (StringUtils.isBlank(token)) {
|
||||
JSONObject returnJson = getAccessToken();
|
||||
log.error("returnJson:{}",returnJson.toJSONString());
|
||||
|
||||
if(returnJson.containsKey("access_token")){
|
||||
token = returnJson.getString("access_token");
|
||||
String expire = returnJson.getString("expires_in");
|
||||
log.error("token22:{}",token);
|
||||
log.error("expire22:{}",expire);
|
||||
if(StringUtils.isNotBlank(expire)){
|
||||
int expire2 = earlySecond;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(expire)){
|
||||
expire2 = Integer.valueOf(expire);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e3:{}",e);
|
||||
}
|
||||
log.error("expire23:{}",expire2);
|
||||
if(expire2 > 0){
|
||||
log.error("expire3:{}",expire2);
|
||||
baseCache.set(BeisenTokenModuleKey.BENSENTOKEN_DATACENTER, BeisenTokenCacheKey.BEISEN_TOKEN, token, expire2-earlySecond);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e2:{}",e);
|
||||
}
|
||||
|
||||
log.error("token4:{}",token);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/***
|
||||
* http方式请求获取token
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getAccessToken(){
|
||||
JSONObject accessTokenJson = new JSONObject();
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("app_key", Constants.app_key);
|
||||
bodyJson.put("app_secret",Constants.app_secret);
|
||||
bodyJson.put("grant_type","client_credentials");
|
||||
|
||||
log.error("bodyJson:{}",bodyJson);
|
||||
//"https://openapi.italent.cn/token"
|
||||
// "{\n \"grant_type\":\"client_credentials\",\n \"app_key\":\"0F0F2B3F6356464EB59FB651E8DAACBA\",\n \"app_secret\":\"AF4A2BFC6BB741FD9D80B7F56DA07F08F703AC14B40C453E8DA5BCABAF43A003\"\n}"
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.tokenUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
accessTokenJson = JSONObject.parseObject(msg);
|
||||
}
|
||||
}else{
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("IOException:{}",e);
|
||||
}
|
||||
return accessTokenJson;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param token
|
||||
* @param beishenHost
|
||||
* @param offerUrl
|
||||
* @param startDate
|
||||
* @param startTime
|
||||
* @param endDate
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
// public JSONArray queryOfferByDateTime(String token, String beishenHost, String offerUrl, String startDate, String startTime, String endDate, String endTime){
|
||||
//
|
||||
// // https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
//// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
// JSONArray offerArray = new JSONArray();
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
// bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
// bodyJson.put("timeWindowQueryType","1");
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(beishenHost+offerUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
//
|
||||
// int code = response.code();
|
||||
// String msg = response.body().string();
|
||||
// System.out.println("code:"+code);
|
||||
// if(code == 200){
|
||||
// if(StringUtils.isNotBlank(msg)){
|
||||
// JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
// if(returnJson.containsKey("code")){
|
||||
// String dataCode = returnJson.getString("code");
|
||||
// if("200".equals(dataCode)){
|
||||
// JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
// offerArray.addAll(dataArray);
|
||||
// String scrollId = returnJson.getString("scrollId");
|
||||
// if(StringUtils.isNotBlank(scrollId)){
|
||||
// queryOfferByscrollId(token,beishenHost, offerUrl, startDate, startTime, endDate, endTime,offerArray);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return offerArray;
|
||||
// }
|
||||
|
||||
// /***
|
||||
// *
|
||||
// * @param token
|
||||
// * @param beishenHost
|
||||
// * @param offerUrl
|
||||
// * @param startDate
|
||||
// * @param startTime
|
||||
// * @param endDate
|
||||
// * @param endTime
|
||||
// * @param offerArray
|
||||
// */
|
||||
// public void queryOfferByscrollId(String token, String beishenHost, String offerUrl, String startDate, String startTime, String endDate, String endTime,JSONArray offerArray){
|
||||
//
|
||||
// // https://openapi.italent.cn/TenantBaseExternal/api/v5/Offer/GetByTimeWindow
|
||||
//// "{\n \"startTime\": \"2025-06-01T00:00:00\", \n \"stopTime\": \"2025-06-21T00:00:00\",\n \"timeWindowQueryType\": 1\n}"
|
||||
//
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// bodyJson.put("startTime",startDate+"T"+startTime);
|
||||
// bodyJson.put("stopTime",endDate+"T"+endTime);
|
||||
// bodyJson.put("timeWindowQueryType","1");
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(beishenHost+offerUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .addHeader("Authorization", "Bearer "+token)
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
//
|
||||
// int code = response.code();
|
||||
// String msg = response.body().string();
|
||||
// log.error("code:{}",code);
|
||||
// if(code == 200){
|
||||
// if(StringUtils.isNotBlank(msg)){
|
||||
// JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
// if(returnJson.containsKey("code")){
|
||||
// String dataCode = returnJson.getString("code");
|
||||
// if("200".equals(dataCode)){
|
||||
// JSONArray dataArray = returnJson.getJSONArray("data");
|
||||
// offerArray.addAll(dataArray);
|
||||
// String scrollId = returnJson.getString("scrollId");
|
||||
// if(StringUtils.isNotBlank(scrollId)){
|
||||
// queryOfferByscrollId(token,beishenHost, offerUrl, startDate, startTime, endDate, endTime,dataArray);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// log.error("msg:"+msg);
|
||||
// }
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
|
||||
public static String HrmHost = "https://hrtest.chabaidao.com";
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.util.CommonUtils;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sapi/secondev/cbd/hrm")
|
||||
public class ConvertStaffCodeController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ConvertStaffCodeController.class);
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
|
||||
@Autowired
|
||||
CommonUtils CommonUtils;
|
||||
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/convStaffCode")
|
||||
public WeaResult<Object> convStaffCode(@RequestBody Map<String, Object> params){
|
||||
Map<String,Object> recordMap = convertStaffCodeService.convStaffCode(params);
|
||||
return WeaResult.success(recordMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sapi/secondev/cbd/workflow")
|
||||
public class Request2CostControlController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(Request2CostControlController.class);
|
||||
|
||||
@Autowired
|
||||
Request2CostControlService request2CostControlService;
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/queryRequestByWorkflowType")
|
||||
public WeaResult<Object> queryRequestByWorkflowType(@RequestBody Map<String, Object> params) {
|
||||
log.error("queryRequestByWorkflowType");
|
||||
|
||||
// int pageNo2 = 1;
|
||||
// int pgeSize2 = 100;
|
||||
// boolean noIsNumber = false;
|
||||
// if(params.containsKey("pageNo")){
|
||||
// String page_no = String.valueOf(params.get("pageNo"));
|
||||
// if(StringUtils.isNotBlank(page_no)){
|
||||
// try {
|
||||
// pageNo2 = Integer.getInteger(page_no);
|
||||
// log.error("pageNo:{}",pageNo2);
|
||||
// noIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// noIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean sizeIsNumber = false;
|
||||
// if(params.containsKey("pageSize")){
|
||||
// String page_size = String.valueOf(params.get("pageSize"));
|
||||
// if(StringUtils.isNotBlank(page_size)){
|
||||
// try {
|
||||
// pgeSize2 = Integer.getInteger(page_size);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
// sizeIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// sizeIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
int page_no = 1;
|
||||
boolean pageIsNumber = false;
|
||||
if(params.containsKey("page")){
|
||||
String page = String.valueOf(params.get("page"));
|
||||
log.error("page:{}",page);
|
||||
if(StringUtils.isNotBlank(page)){
|
||||
try {
|
||||
page_no = Integer.valueOf(page);
|
||||
log.error("page_no:{}",page_no);
|
||||
pageIsNumber = true;
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("e:{}",e);
|
||||
pageIsNumber = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("pageIsNumber:{}",pageIsNumber);
|
||||
log.error("page_no:{}",page_no);
|
||||
//
|
||||
// log.error("sizeIsNumber:{}",sizeIsNumber);
|
||||
// log.error("noIsNumber:{}",noIsNumber);
|
||||
// log.error("pageNo2:{}",pageNo2);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
|
||||
int pageSize = 100;
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String staffcode = String.valueOf(params.get("staffCode"));
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String workflowId = String.valueOf(params.get("workflowId"));
|
||||
if(StringUtils.isNotBlank(workflowId)){
|
||||
Long workflowid = Long.parseLong(workflowId);
|
||||
Long employeeId = convertStaffCodeService.convEmployeeIdByCode(staffcode);
|
||||
if(employeeId > 0){
|
||||
dataMap = request2CostControlService.queryRequestByWorkflowType(params,workflowid,page_no,pageSize,employeeId);
|
||||
}else{
|
||||
return WeaResult.fail("工号转换,未获取到员工id");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("流程ID获取为空");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("员工工会stffcode为空");
|
||||
}
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/cbd/workflownew")
|
||||
public class RequestInfoController {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(RequestInfoController.class);
|
||||
|
||||
@Autowired
|
||||
Request2CostControlService request2CostControlService;
|
||||
|
||||
@Autowired
|
||||
ConvertStaffCodeService convertStaffCodeService;
|
||||
@WeaPermission(publicPermission = true)
|
||||
@GetMapping("/queryRequestByWorkflowType")
|
||||
public WeaResult<Object> queryRequestByWorkflowType(@RequestBody Map<String, Object> params) {
|
||||
log.error("queryRequestByWorkflowType2");
|
||||
|
||||
// int pageNo2 = 1;
|
||||
// int pgeSize2 = 100;
|
||||
// boolean noIsNumber = false;
|
||||
// if(params.containsKey("pageNo")){
|
||||
// String page_no = String.valueOf(params.get("pageNo"));
|
||||
// if(StringUtils.isNotBlank(page_no)){
|
||||
// try {
|
||||
// pageNo2 = Integer.getInteger(page_no);
|
||||
// log.error("pageNo:{}",pageNo2);
|
||||
// noIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// noIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean sizeIsNumber = false;
|
||||
// if(params.containsKey("pageSize")){
|
||||
// String page_size = String.valueOf(params.get("pageSize"));
|
||||
// if(StringUtils.isNotBlank(page_size)){
|
||||
// try {
|
||||
// pgeSize2 = Integer.getInteger(page_size);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
// sizeIsNumber = true;
|
||||
// } catch (NumberFormatException e) {
|
||||
// sizeIsNumber = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
int page_no = 1;
|
||||
boolean pageIsNumber = false;
|
||||
if(params.containsKey("page")){
|
||||
String page = String.valueOf(params.get("page"));
|
||||
log.error("page:{}",page);
|
||||
if(StringUtils.isNotBlank(page)){
|
||||
try {
|
||||
page_no = Integer.valueOf(page);
|
||||
log.error("page_no:{}",page_no);
|
||||
pageIsNumber = true;
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("e:{}",e);
|
||||
pageIsNumber = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("pageIsNumber2:{}",pageIsNumber);
|
||||
log.error("page_no2:{}",page_no);
|
||||
//
|
||||
// log.error("sizeIsNumber:{}",sizeIsNumber);
|
||||
// log.error("noIsNumber:{}",noIsNumber);
|
||||
// log.error("pageNo2:{}",pageNo2);
|
||||
// log.error("pgeSize2:{}",pgeSize2);
|
||||
|
||||
int pageSize = 100;
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String staffcode = String.valueOf(params.get("staffCode"));
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String workflowId = String.valueOf(params.get("workflowId"));
|
||||
if(StringUtils.isNotBlank(workflowId)){
|
||||
Long workflowid = Long.parseLong(workflowId);
|
||||
Long employeeId = convertStaffCodeService.convEmployeeIdByCode(staffcode);
|
||||
if(employeeId > 0){
|
||||
dataMap = request2CostControlService.queryRequestByWorkflowType(params,workflowid,page_no,pageSize,employeeId);
|
||||
}else{
|
||||
return WeaResult.fail("工号转换,未获取到员工id");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("流程ID获取为空");
|
||||
}
|
||||
}else{
|
||||
return WeaResult.fail("员工工会stffcode为空");
|
||||
}
|
||||
return WeaResult.success(dataMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.cost.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.cost.util.DatabaseUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class ConvertStaffCodeDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConvertStaffCodeDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryEmployeeById(String staffcode){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> recordMap = new HashMap<String,Object>();
|
||||
try{
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String dataSql =" select id,username " +
|
||||
" from eteams.employee " +
|
||||
" where job_num = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(staffcode);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}else{
|
||||
recordMap.put("id","");
|
||||
recordMap.put("username","");
|
||||
}
|
||||
}else{
|
||||
recordMap.put("id","");
|
||||
recordMap.put("username","");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
public Long queryEmployeeByCode(String staffcode){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Long employeeId = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String dataSql =" select id,username " +
|
||||
" from eteams.employee " +
|
||||
" where job_num = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(staffcode);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(!recordList.isEmpty()){
|
||||
employeeId = Long.parseLong(String.valueOf(recordList.get(0).get("id")));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface ConvertStaffCodeService {
|
||||
Map<String,Object> convStaffCode(Map<String,Object> paraMap);
|
||||
|
||||
Long convEmployeeIdByCode(String staffcode);
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public interface Request2CostControlService {
|
||||
Map<String, Object> queryRequestByWorkflowType(Map<String, Object> params,Long workflowid,int pageNo,int pageSize,Long employeeId);
|
||||
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service.impl;
|
||||
|
||||
import com.weaver.seconddev.chapanda.cost.dao.ConvertStaffCodeDao;
|
||||
import com.weaver.seconddev.chapanda.cost.service.ConvertStaffCodeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class ConvertStaffCodeServiceImpl implements ConvertStaffCodeService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(ConvertStaffCodeServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ConvertStaffCodeDao convertStaffCodeDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paraMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> convStaffCode(Map<String, Object> paraMap) {
|
||||
String staffcode = String.valueOf(paraMap.get("staffcode"));
|
||||
log.error("staffcode:{}",staffcode);
|
||||
Map<String, Object> dataMap = convertStaffCodeDao.queryEmployeeById(staffcode);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long convEmployeeIdByCode(String staffcode) {
|
||||
log.error("staffcode:{}",staffcode);
|
||||
Long employeeId = convertStaffCodeDao.queryEmployeeByCode(staffcode);
|
||||
log.error("employeeId:{}",employeeId);
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.service.impl;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.cost.service.Request2CostControlService;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum;
|
||||
import com.weaver.workflow.common.entity.list.api.RequestListConditionApiEntity;
|
||||
import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEntity;
|
||||
import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity;
|
||||
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* author:shil
|
||||
*/
|
||||
@Service
|
||||
public class Request2CostControlServiceImpl implements Request2CostControlService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(Request2CostControlServiceImpl.class);
|
||||
|
||||
@RpcReference(group = "workflow")
|
||||
WflRequestListRest wflRequestListRest;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryRequestByWorkflowType(Map<String, Object> params,Long workflowid,int pageNo,int pageSize,Long employeeId) {
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
log.error("queryRequestByWorkflowType");
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
|
||||
log.error("simpleEmployee:{}",simpleEmployee.getId());
|
||||
|
||||
List<Map<String, Object>> requestList = new ArrayList<Map<String, Object>>();
|
||||
|
||||
Long total = 0L;
|
||||
try{
|
||||
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
|
||||
|
||||
List<Long> workflowIdList = new ArrayList<Long>();
|
||||
workflowIdList.add(workflowid);
|
||||
conditionEntity.setWorkflowIdList(workflowIdList);
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String requestmark = String.valueOf(params.get("requestRemark"));
|
||||
String staffCode = String.valueOf(params.get("staffCode"));
|
||||
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("staffCode:{}",staffCode);
|
||||
|
||||
conditionEntity.setCreater(employeeId);
|
||||
|
||||
if(StringUtils.isNotBlank(requestName)){
|
||||
conditionEntity.setRequestname(requestName);
|
||||
}
|
||||
if(StringUtils.isNotBlank(requestmark)){
|
||||
conditionEntity.setRequestmark(requestmark);
|
||||
}
|
||||
|
||||
WeaResult<RequestCountInfoPAEntity> requestCountInfo = wflRequestListRest.getRequestCountByTabId(simpleEmployee, RequestListInitDimensionTabEnum.DONE_FINISH.getTabid(),conditionEntity);
|
||||
int countCode = requestCountInfo.getCode();
|
||||
log.error("countCode:{}",countCode);
|
||||
if(countCode == 200){
|
||||
total = requestCountInfo.getData().getCount();
|
||||
}
|
||||
log.error("total:{}",total);
|
||||
dataMap.put("total",total);
|
||||
|
||||
WeaResult<List<RequestListInfoPAEntity>> requestInfoList = wflRequestListRest.getRequestListByTabId(simpleEmployee, RequestListInitDimensionTabEnum.DONE_FINISH.getTabid(), pageNo, pageSize, conditionEntity);
|
||||
int code = requestInfoList.getCode();
|
||||
log.error("code:{}",code);
|
||||
if(code == 200){
|
||||
List<RequestListInfoPAEntity> requestListInfo = requestInfoList.getData();
|
||||
log.error("requestListInfo:{}",requestListInfo.size());
|
||||
|
||||
for(int i=0;i<requestListInfo.size();i++){
|
||||
RequestListInfoPAEntity requestListInfoPAEntity = requestListInfo.get(i);
|
||||
String request_Name = requestListInfoPAEntity.getRequestname();
|
||||
String request_remark = requestListInfoPAEntity.getRequestMark();
|
||||
String requestcode = requestListInfoPAEntity.getRequestCode();
|
||||
String appUrl = requestListInfoPAEntity.getAppUrl();
|
||||
String createTime = requestListInfoPAEntity.getCreateTime().toString();
|
||||
String creatorName = requestListInfoPAEntity.getCreatorName();
|
||||
String pcUrl = requestListInfoPAEntity.getPcUrl();
|
||||
|
||||
Map<String, Object> requestMap = new HashMap<String, Object>();
|
||||
requestMap.put("requestName",request_Name);
|
||||
requestMap.put("requestremark",request_remark);
|
||||
requestMap.put("requestcode",requestcode);
|
||||
requestMap.put("appUrl",appUrl);
|
||||
requestMap.put("createTime",createTime);
|
||||
requestMap.put("creatorName",creatorName);
|
||||
requestMap.put("pcUrl",pcUrl);
|
||||
requestList.add(requestMap);
|
||||
}
|
||||
}
|
||||
dataMap.put("data",requestList);
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e.getMessage());
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,366 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.cost.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1147262704872284161";
|
||||
|
||||
public static String dmpHost = "http://internaldataservice-uat.shuxinyc.com";
|
||||
|
||||
public static String gmvUrl = "/api/internal-data-service/hr/shop/gmv";
|
||||
|
||||
public static String token = "xYXL37XoV7xlOnNSdJW44iat";
|
||||
|
||||
}
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.DatabaseUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FormFieldDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(FormFieldDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldId
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFieldOptionByFieldid(String fieldId){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> optionMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select name,value_key from field_option where field_id=? " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(fieldId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String name = String.valueOf(recordMap.get("name"));
|
||||
String value_key = String.valueOf(recordMap.get("value_key"));
|
||||
optionMap.put(value_key,name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return optionMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryTableFormId(String tableName){
|
||||
String sourceType = "LOGIC";
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataSql =" select id,app_id from ebdf_obj where table_name=? and delete_type=0 and tenant_key=?" ;
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(tableName);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryTableFormId:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryTableFormId:e:" + e);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataKeyList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFromTableField(String formTable,List<String> dataKeyList){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> fieldMap = new HashMap<String, Object>();
|
||||
try{
|
||||
String dataKey = dataKeyList.stream().collect(Collectors.joining(","));
|
||||
dataKey = "'"+dataKey.replace(",","','")+"'" ;
|
||||
|
||||
String dataSql =" select id,form_id,title,data_key " +
|
||||
" from form_field " +
|
||||
" where form_id in( select form_id from form_table where table_name=? and delete_type=0 and tenant_key=? ) \n" +
|
||||
" and data_key in("+dataKey+")\n" +
|
||||
" and sub_form_id is null " +
|
||||
" and tenant_key=? \n" +
|
||||
" and delete_type=0" ;
|
||||
|
||||
log.error("queryFromTableField--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(formTable);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryFromTableField:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String data_key = String.valueOf(recordMap.get("data_key"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
fieldMap.put(data_key,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryFromTableField:e:" + e);
|
||||
}
|
||||
return fieldMap;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryDepartmentList(){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
try{
|
||||
|
||||
String dataSql =" select code,id from eteams.department and tenant_key=? and delete_type=0" ;
|
||||
log.error("queryDepartmentList--dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
for(Map<String,Object> recordMap : recordList ) {
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String id = String.valueOf(recordMap.get("id"));
|
||||
dataMap.put(code,id);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
public String getGmvIdByCode(String code,String formTable,String dataKey){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String dataId = "";
|
||||
try{
|
||||
|
||||
String dataSql =" select id from "+formTable+" and tenant_key=? and delete_type=0 and "+dataKey+"=?" ;
|
||||
log.error("dataSql:{}", dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(code);
|
||||
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("queryDepartmentList:"+recordList.size());
|
||||
if(recordList.size()>0){
|
||||
dataId = String.valueOf(recordList.get(0).get("id"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("queryDepartmentList:{} ", e);
|
||||
}
|
||||
return dataId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.dmp.util.Esb2DmpGetGmvUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2DmpGetGmvCron")
|
||||
public class Esb2DmpGetGmvCron implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2DmpGetGmvCron.class);
|
||||
@Autowired
|
||||
Esb2DmpGetGmvUtil esb2DmpGetGmvUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2DmpGetGmvCron start");
|
||||
String type = String.valueOf(params.get("type"));
|
||||
String startDate = "";
|
||||
String endDate = "";
|
||||
String year = String.valueOf(params.get("year"));
|
||||
if("1".equals(type)){
|
||||
startDate = year+"-01-01";
|
||||
endDate = year+"-12-31";
|
||||
}else{
|
||||
startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).toString();
|
||||
endDate = LocalDate.now().toString();
|
||||
}
|
||||
List<String> ebList = esb2DmpGetGmvUtil.queryGmvList(startDate,endDate);
|
||||
log.error("ebList:{}",ebList.size());
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2DmpGetGmvCron");
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class CommonUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
|
||||
|
||||
public static JSONObject toJSON(String data){
|
||||
if(!StringUtils.isEmpty(data)){
|
||||
try {
|
||||
return JSONObject.parseObject(data);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getJSONLong(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getLong(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getJSONInteger(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getInteger(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJSONString(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return null2String(json.getString(key));
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONObject json,String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONObject(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONArray getJSONArray(JSONObject json, String key){
|
||||
if(json != null && json.containsKey(key)){
|
||||
try {
|
||||
return json.getJSONArray(key);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(JSONArray json, int idx){
|
||||
if(json != null && json.size() > idx){
|
||||
try {
|
||||
return json.getJSONObject(idx);
|
||||
}catch (Throwable t){
|
||||
log.error(t.getMessage(),t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String mapToStrData(Map<String, Object> para){
|
||||
if(para != null) {
|
||||
return JSONObject.toJSON(para).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs){
|
||||
strToLongList(list,strs,true);
|
||||
}
|
||||
|
||||
public static void strToLongList(List<Long> list,String strs,boolean isDist){
|
||||
if(list == null){
|
||||
return;
|
||||
}
|
||||
if(StringUtils.isEmpty(strs)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] strList = StringUtils.split(strs, ",");
|
||||
for(String str:strList){
|
||||
if(StringUtils.isEmpty(str)){
|
||||
continue;
|
||||
}
|
||||
|
||||
long id = getLongValue(str);
|
||||
if(id > 0l && (isDist == false || !list.contains(id))){
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(Object v){
|
||||
return getLongValue(null2String(v));
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(Object o){
|
||||
return getIntValue(null2String(o));
|
||||
}
|
||||
|
||||
public static int getIntValue(String s){
|
||||
return getIntValue(s,-1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String s, int def){
|
||||
try {
|
||||
return NumberUtils.toInt(s);
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String null2String(Object s) {
|
||||
return s == null ? "" : s.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object s, String def) {
|
||||
return s == null ? (def == null ? "" : def) : s.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String stringReplace(String sou, String s1, String s2) {
|
||||
//int idx = sou.indexOf(s1);
|
||||
//if (idx < 0) {
|
||||
// return sou;
|
||||
//}
|
||||
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
|
||||
sou = null2String(sou);
|
||||
s1 = null2String(s1);
|
||||
s2 = null2String(s2);
|
||||
try{
|
||||
sou = sou.replace(s1, s2);
|
||||
}catch(Exception e){
|
||||
//System.out.println(e);//将未知异常打印出来,便于检查错误。
|
||||
}
|
||||
return sou;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toScreen(String s) {
|
||||
char c[] = s.toCharArray();
|
||||
char ch;
|
||||
int i = 0;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (i < c.length) {
|
||||
ch = c[i++];
|
||||
|
||||
if (ch == '\r')
|
||||
buf.append("");
|
||||
else if (ch == '\n')
|
||||
buf.append("");
|
||||
else
|
||||
buf.append(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换特殊字符
|
||||
*
|
||||
* @param s 要替换特殊的字符串
|
||||
* @return 替换完成的字符串
|
||||
*/
|
||||
public static String toExcel(String s) {
|
||||
if (s == null) return "";
|
||||
//因本方法会将字符串 &符号转换,故先将欧元符号转义符转换为其Unicode码
|
||||
s = s.replaceAll("€", "\u20AC");
|
||||
String str = toScreen(s);
|
||||
str = stringReplace(str, "∠", "∠");
|
||||
str = stringReplace(str, "φ", "φ");
|
||||
str = stringReplace(str, """, "\"");
|
||||
str = stringReplace(str, " ", "%nbsp");
|
||||
//str=Util.StringReplace(str,"'","‘");
|
||||
str = stringReplace(str, "<", "<");
|
||||
str = stringReplace(str, ">", ">");
|
||||
str = stringReplace(str, "&dt;&at;", "<br>");
|
||||
str = stringReplace(str, "&", "&");
|
||||
str = stringReplace(str, "<br>", "&dt;&at;");
|
||||
if ("&dt;&at;".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
//在方法最后,又将欧元符号置换为转义符
|
||||
str = str.replaceAll("\u20AC", "€");
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String delHtml(final String inputString) {
|
||||
String htmlStr = toExcel(inputString); // 含html标签的字符串
|
||||
|
||||
String textStr = "";
|
||||
java.util.regex.Pattern p_script;
|
||||
java.util.regex.Matcher m_script;
|
||||
java.util.regex.Pattern p_html;
|
||||
java.util.regex.Matcher m_html;
|
||||
|
||||
try {
|
||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||
|
||||
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
|
||||
|
||||
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_script = p_script.matcher(htmlStr);
|
||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
||||
|
||||
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
|
||||
m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
||||
|
||||
textStr = htmlStr;
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Html2Text: " + e.getMessage());
|
||||
}
|
||||
|
||||
return htmlToTxt(textStr).trim();// 返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的html格式
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static String htmlToTxt(String input) {
|
||||
if (input == null || input.trim().equals("")) {
|
||||
return "";
|
||||
}
|
||||
// 去掉所有html元素,
|
||||
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//==new=
|
||||
|
||||
public static int getIntValue(Object s, int def){
|
||||
return getIntValue(null2String(s));
|
||||
}
|
||||
|
||||
public static List<Long> strToLongList(String strs){
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
strToLongList(list,strs,true);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static int dateInterval(String fromdate, String todate) {
|
||||
Calendar fromcalendar = getCalendar(fromdate);
|
||||
Calendar tocalendar = getCalendar(todate);
|
||||
|
||||
if (fromcalendar == null || tocalendar == null)
|
||||
return 0;
|
||||
|
||||
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间,格式为 '2004-05-12 12:00:23' 或者 '2004-05-12'
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime) {
|
||||
int datetimelength = datetime.length() ;
|
||||
|
||||
switch(datetimelength) {
|
||||
case 19 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
|
||||
case 10 :
|
||||
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
|
||||
default :
|
||||
return null ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param datetime - 给定的日期时间
|
||||
* @param formart - 给定的日期时间的格式
|
||||
* @return 返回给定日历, 如果格式不正确,返回null
|
||||
*/
|
||||
public static Calendar getCalendar(String datetime, String formart) {
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
|
||||
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
try {
|
||||
calendar.setTime(SDF.parse(datetime)) ;
|
||||
} catch (ParseException e) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
return calendar ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回当前时间字符,格式为 yyyy'-'MM'-'dd
|
||||
*
|
||||
* 返回当前时间字符,默认格式为yyyy'-'MM'-'dd
|
||||
*
|
||||
* 如 2004-09-07
|
||||
*/
|
||||
public static String getCurrentDateString() {
|
||||
String timestrformart = "yyyy'-'MM'-'dd" ;
|
||||
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
|
||||
Calendar calendar = Calendar.getInstance() ;
|
||||
|
||||
return SDF.format(calendar.getTime()) ;
|
||||
}
|
||||
|
||||
public static String getMessage(String msgMode,String key,String val){
|
||||
key = null2String(key).trim();
|
||||
val = null2String(val).trim();
|
||||
msgMode = null2String(msgMode).trim();
|
||||
if(!"".equals(msgMode) && !"".equals(key)) {
|
||||
msgMode = msgMode.replaceAll(key, val);
|
||||
}
|
||||
return msgMode;
|
||||
}
|
||||
|
||||
public static List<Long> tranStrToLongList(Object idListObj){
|
||||
List<Long> docIds = new ArrayList<Long>();
|
||||
if(idListObj != null) {
|
||||
try {
|
||||
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
|
||||
for (Object idObj : idObjs) {
|
||||
long id = getLongValue(idObj);
|
||||
if (id > 0l) {
|
||||
docIds.add(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("trans error :{}", idListObj);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return docIds;
|
||||
}
|
||||
|
||||
public Map<String, Object> requestToMap(HttpServletRequest request) {
|
||||
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
|
||||
String name = "";
|
||||
String value = "";
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, String[]> entry = iter.next();
|
||||
name = entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = "";
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
value = values[i] + ",";
|
||||
}
|
||||
value = value.substring(0, value.length() - 1);
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,367 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
|
||||
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
|
||||
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
|
||||
import com.weaver.seconddev.chapanda.beisen.util.CommonUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* DatabaseUtil 是一个数据库工具类,提供了一些执行 SQL 查询和操作的方法。
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
public class DatabaseUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
@Autowired
|
||||
private EbFormDataService dataService;
|
||||
|
||||
|
||||
/**
|
||||
* 执行 SQL 并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 的相关信息的对象
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
|
||||
Map<String, Object> map = dataSetService.executeSql(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行分页 SQL 查询并返回结果。
|
||||
*
|
||||
* @param entity 包含执行 SQL 和分页信息的对象
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页的数据条数
|
||||
* @return 包含查询结果的 Map 对象
|
||||
* @throws RuntimeException 当 SQL 执行失败时抛出异常
|
||||
*/
|
||||
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
|
||||
entity.setPageNo(pageNo);
|
||||
entity.setPageSize(pageSize);
|
||||
Map<String, Object> map = dataSetService.executeForQuery(entity);
|
||||
if ("FAIL".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
|
||||
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
|
||||
throw new RuntimeException("sql执行异常");
|
||||
} else {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个包含执行 SQL 的对象。
|
||||
*
|
||||
* @param sql 需要执行的 SQL
|
||||
* @param groupId 数据源分组的 ID
|
||||
* @paramDesc 数据源分组的 ID 获取方式 【select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation】
|
||||
* @return 包含执行 SQL 的对象
|
||||
*/
|
||||
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
|
||||
log.error("sql=>{}", sql);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.LOGIC);
|
||||
executeSqlEntity.setGroupKey("0");
|
||||
return executeSqlEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 SQL 进行 Base64 编码。
|
||||
*
|
||||
* @param sql 需要进行编码的 SQL
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
public String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源列表。
|
||||
*
|
||||
* @param map 包含数据源列表信息的 Map 对象
|
||||
* @return 数据源列表的 Map 对象
|
||||
*/
|
||||
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = new ArrayList();
|
||||
if ("OK".equals(CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
|
||||
entity = (List) map.get("records");
|
||||
}
|
||||
|
||||
return keyToLowerCase((List) entity);
|
||||
}
|
||||
|
||||
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
|
||||
List<Map<String, Object>> entity = getDataSourceList(map);
|
||||
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMapList 需要转换键的 Map 对象列表
|
||||
* @return 转换后的 Map 对象列表
|
||||
*/
|
||||
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
|
||||
List<Map<String, Object>> resultList = new ArrayList();
|
||||
Iterator var2 = orgMapList.iterator();
|
||||
|
||||
while (var2.hasNext()) {
|
||||
Map<String, Object> stringObjectMap = (Map) var2.next();
|
||||
resultList.add(keyToLowerCase(stringObjectMap));
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Map 对象中的键转换为小写。
|
||||
*
|
||||
* @param orgMap 需要转换键的 Map 对象
|
||||
* @return 转换后的 Map 对象
|
||||
*/
|
||||
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
if (orgMap != null && !orgMap.isEmpty()) {
|
||||
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
|
||||
Iterator var3 = entrySet.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
|
||||
String key = (String) entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
resultMap.put(key.toLowerCase(), value);
|
||||
}
|
||||
return resultMap;
|
||||
} else {
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据库类型 找到对应数据库
|
||||
*
|
||||
* @param sourceType sourceType 枚举类
|
||||
* ETEAMS :数据仓库
|
||||
* FORM: ebuilder表单
|
||||
* LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* EXTERNAL: 外部数据源
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
|
||||
GroupQuery query = new GroupQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setShowSqlDataset(flag);
|
||||
|
||||
|
||||
DynamicParamDto dynamicParamDto = new DynamicParamDto();
|
||||
dynamicParamDto.setUserId(10000L);
|
||||
dynamicParamDto.setTenantKey("tk");
|
||||
|
||||
query.setDynamicParamDto(dynamicParamDto);
|
||||
|
||||
return dataSetService.getDataGroups(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据表
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
|
||||
|
||||
TableQuery tableQuery = new TableQuery();
|
||||
tableQuery.setSourceType(SourceType.valueOf(sourceType));
|
||||
tableQuery.setGroupId(groupId);
|
||||
//非必传
|
||||
//tableQuery.setName(name);
|
||||
tableQuery.setPageNo(pageNum);
|
||||
tableQuery.setPageSize(pageSize);
|
||||
return dataSetService.getDataSetsByPage(tableQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表字段
|
||||
* sourceType :LOGIC
|
||||
* sourceId : 8494845523559165780
|
||||
* groupId : weaver-crm-service
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
|
||||
FieldQuery query = new FieldQuery();
|
||||
query.setSourceType(SourceType.valueOf(sourceType));
|
||||
query.setSourceId(sourceId);
|
||||
query.setGroupId(groupId);
|
||||
return dataSetService.getFields(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行sql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service
|
||||
* sql : select * from ebda_app limit 10
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeUpdate(String sourceType, String groupId, String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @param sqlparam
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeForUpdate(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||
executeSqlEntity.setParams(sqlparam);
|
||||
return dataSetService.executeForUpdate(executeSqlEntity);
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sql
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
|
||||
if(pageNo<=0){
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
if(pageSize<=0){
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
int start = (pageNo-1)*pageSize;
|
||||
int end = pageNo*pageSize;
|
||||
|
||||
return new StringBuffer().append(sql).append(
|
||||
" LIMIT "+start+","+(end-start)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sql入参
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
|
||||
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
|
||||
for (String str : list){
|
||||
SqlParamEntity sqlParamEntity = new SqlParamEntity();
|
||||
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParamEntity.setValue(str);
|
||||
sqlparam.add(sqlParamEntity);
|
||||
}
|
||||
return sqlparam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sourceType
|
||||
* @param groupId
|
||||
* @param dataSql
|
||||
* @param paramList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
|
||||
Map<String, Object> recordMap = new HashMap<String, Object>();
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = getDataSourceList(result);
|
||||
if(recordList.size() > 0){
|
||||
recordMap = recordList.get(0);
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.weaver.ebuilder.form.client.entity.data.*;
|
||||
import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService;
|
||||
import com.weaver.framework.rpc.annotation.RpcReference;
|
||||
import com.weaver.publishkit.api.util.PublishKitRuntimeUtil;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class EbuilderOperateUtils {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(EbuilderOperateUtils.class);
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
@Autowired
|
||||
private PublishKitRuntimeUtil publishKitRuntimeUtil;
|
||||
|
||||
@RpcReference(group = "ebuilderform")
|
||||
private RemoteSimpleDataService remoteSimpleDataService;
|
||||
|
||||
public EBDataChangeResult bacthInsertDbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
log.error("bacthInsertDbForm");
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
|
||||
if(StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)){
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
|
||||
EBDataReqOperation operation = new EBDataReqOperation();
|
||||
operation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(operation);
|
||||
|
||||
// 主表数据参数
|
||||
// Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
// if("uf_yzgl".equals(formTable)){
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(fieldList.get(n).equals("yzzl")){
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, "2"));
|
||||
// }else{
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }else{
|
||||
// for(int i=0;i<dataList.size();i++){
|
||||
// Map<String,Object> dataMap = dataList.get(i);
|
||||
// EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
// List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
// for(int n=0;n<fieldList.size();n++){
|
||||
// if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
// String value = dataMap.get(fieldList.get(n)).toString();
|
||||
// String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
//
|
||||
// log.error("fieldId:{}",fieldId);
|
||||
// log.error("value:{}",value);
|
||||
//
|
||||
// mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
// }
|
||||
// }
|
||||
// ebDataReqDto.setMainDatas(mainData);
|
||||
// datas.add(ebDataReqDto);
|
||||
// }
|
||||
// }
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.saveFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
|
||||
public EBDataChangeResult bacthEditEbForm(List<EBDataReqDto> datas,String formId,String appId) {
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = new EBDataChangeResult();
|
||||
if (StringUtils.isNotBlank(formId) && StringUtils.isNotBlank(appId)) {
|
||||
|
||||
RemoteSimpleDataService remoteSimpleDataService = publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", appId);
|
||||
|
||||
/**
|
||||
* 直接通过id更新数据, 即update table set a = '11' where id = 1
|
||||
*/
|
||||
EBDataChangeReqDto ebDataChangeReqDto = new EBDataChangeReqDto();
|
||||
// 构建基础参数; objId 表单id, operator 操作人, tenantKey 租户
|
||||
ebDataChangeReqDto.setHeader(new EBDataReqHeader(formId, Constants.SysUserId, Constants.TENANT_KEY));
|
||||
// 请求操作信息
|
||||
EBDataReqOperation ebDataReqOperation = new EBDataReqOperation();
|
||||
ebDataReqOperation.setUpdateType(EBDataUpdateType.ids);
|
||||
// 若数据写入后就要从前台看到数据或者立即操作本次写入的数据, 需要调整后置处理为同步 权限处理完成再返回
|
||||
ebDataReqOperation.setAsyncPostProcess(false);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
// 数据没有找到的时候是否新增数据
|
||||
EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo();
|
||||
ebDataReqOperationInfo.setNeedAdd(true);
|
||||
ebDataReqOperation.setMainData(ebDataReqOperationInfo);
|
||||
ebDataChangeReqDto.setOperation(ebDataReqOperation);
|
||||
ebDataChangeReqDto.setDatas(datas);
|
||||
ebDataChangeResult = remoteSimpleDataService.updateFormData(ebDataChangeReqDto);
|
||||
}
|
||||
return ebDataChangeResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.dmp.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto;
|
||||
import com.weaver.seconddev.chapanda.dmp.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.dmp.dao.FormFieldDao;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2DmpGetGmvUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2DmpGetGmvUtil.class);
|
||||
|
||||
@Autowired
|
||||
EbuilderOperateUtils ebuilderOperateUtils;
|
||||
|
||||
@Autowired
|
||||
FormFieldDao formFieldDao;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> queryGmvList(String startDate,String endDate){
|
||||
|
||||
List<String> ebList = new ArrayList<String>();
|
||||
|
||||
List<Map<String,Object>> addList = new ArrayList<Map<String,Object>>();
|
||||
List<Map<String,Object>> updateList = new ArrayList<Map<String,Object>>();
|
||||
String formTable = "uf_zymdgmv";
|
||||
List<String> fieldList = new ArrayList<String>();
|
||||
fieldList.add("mdbm");
|
||||
fieldList.add("mdmc");
|
||||
fieldList.add("gmv");
|
||||
fieldList.add("sjsj");
|
||||
fieldList.add("hrmdid");
|
||||
try {
|
||||
Map<String, Object> deptMap = formFieldDao.queryDepartmentList();
|
||||
String msg = doHttpPost(startDate,endDate);
|
||||
log.error("msg:"+msg);
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject msgJson = JSONObject.parseObject(msg);
|
||||
String dataCode = msgJson.getString("code");
|
||||
if("200".equals(dataCode)){
|
||||
JSONArray dataArray = msgJson.getJSONArray("data");
|
||||
for(int i = 0; i < dataArray.size(); i++){
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
String mdbm = dataJson.getString("orgCode");
|
||||
String mdmc = dataJson.getString("orgCodeName");
|
||||
String gmv = dataJson.getString("gmv");
|
||||
String sjsj = dataJson.getString("reportDate");
|
||||
String hrmdid = "";
|
||||
Map<String,Object> gmvMap = new HashMap<String,Object>();
|
||||
gmvMap.put("mdbm",mdbm);
|
||||
if(StringUtils.isNotBlank(mdbm)){
|
||||
if(deptMap.containsKey(mdbm)){
|
||||
hrmdid = String.valueOf(deptMap.get(mdbm));
|
||||
}
|
||||
}
|
||||
gmvMap.put("hrmdid",hrmdid);
|
||||
if(StringUtils.isNotBlank(gmv)){
|
||||
if(!"null".equals(gmv) && gmv !=null){
|
||||
gmvMap.put("gmv",gmv);
|
||||
}else{
|
||||
gmvMap.put("gmv","");
|
||||
}
|
||||
}else{
|
||||
gmvMap.put("gmv","");
|
||||
}
|
||||
gmvMap.put("mdmc",mdmc);
|
||||
gmvMap.put("sjsj",sjsj);
|
||||
|
||||
String dataId = formFieldDao.getGmvIdByCode(mdbm,formTable,"mdbm");
|
||||
if(StringUtils.isNotBlank(dataId)){
|
||||
gmvMap.put("id",dataId);
|
||||
updateList.add(gmvMap);
|
||||
}else{
|
||||
addList.add(gmvMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,Object> recordMap= formFieldDao.queryTableFormId(formTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
log.error("appId:{}",appId);
|
||||
|
||||
if(!addList.isEmpty()){
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
|
||||
Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
for(int i=0;i<addList.size();i++){
|
||||
Map<String,Object> dataMap = addList.get(i);
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataMap.get(fieldList.get(n)).toString();
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
datas.add(ebDataReqDto);
|
||||
}
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = ebuilderOperateUtils.bacthInsertDbForm(datas,formId,appId);
|
||||
boolean isTrue = ebDataChangeResult.getStatus();
|
||||
if(isTrue){
|
||||
ebList = ebDataChangeResult.getDataIds();
|
||||
}
|
||||
}
|
||||
|
||||
if(!updateList.isEmpty()){
|
||||
|
||||
List<EBDataReqDto> datas = new ArrayList<EBDataReqDto>();
|
||||
Map<String, Object> fieldMap = formFieldDao.queryFromTableField(formTable,fieldList);
|
||||
for(int i=0;i<addList.size();i++){
|
||||
Map<String,Object> dataMap = addList.get(i);
|
||||
EBDataReqDto ebDataReqDto = new EBDataReqDto();
|
||||
List<EBDataReqDetailDto> mainData = new ArrayList<EBDataReqDetailDto>();
|
||||
String id = dataMap.get("id").toString();
|
||||
mainData.add(new EBDataReqDetailDto("id", id));
|
||||
for(int n=0;n<fieldList.size();n++){
|
||||
if(dataMap.containsKey(fieldList.get(n)) && fieldMap.containsKey(fieldList.get(n))){
|
||||
String value = dataMap.get(fieldList.get(n)).toString();
|
||||
String fieldId = fieldMap.get(fieldList.get(n)).toString();
|
||||
log.error("fieldId:{}",fieldId);
|
||||
log.error("value:{}",value);
|
||||
mainData.add(new EBDataReqDetailDto(fieldId, value));
|
||||
}
|
||||
}
|
||||
ebDataReqDto.setMainDatas(mainData);
|
||||
datas.add(ebDataReqDto);
|
||||
}
|
||||
|
||||
EBDataChangeResult ebDataChangeResult = ebuilderOperateUtils.bacthEditEbForm(datas,formId,appId);
|
||||
boolean isTrue = ebDataChangeResult.getStatus();
|
||||
if(isTrue){
|
||||
ebList = ebDataChangeResult.getDataIds();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("e:"+e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ebList;
|
||||
}
|
||||
|
||||
|
||||
public String doHttpPost(String startDate,String endDate) {
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("startDate", startDate);
|
||||
bodyJson.put("endDate", endDate);
|
||||
// "{\n \"startDate\": \"2025-07-01\",\n \"endDate\": \"2025-07-03\"\n}"
|
||||
RequestBody body = RequestBody.create(mediaType, bodyJson.toJSONString());
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.dmpHost + Constants.gmvUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", Constants.token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:{}", code);
|
||||
msg = response.body().string();
|
||||
log.error("msg:" + msg);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("e:" + e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.esign.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
|
||||
public static String SysUserId = "1147262704872284161";
|
||||
|
||||
public static String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
public static String xTimevaleProjectId = "1001003";
|
||||
public static String eSignHost = "http://110.185.172.132:8086";
|
||||
public static String queryTemplateUrl = "/esignpro/rest/template/api/getTemplateInfo";
|
||||
|
||||
public static String querySealsUrl = "/V1/seals/innerOrgansSeals/list";
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignQuerySealsAction")
|
||||
public class Esb2EsignQuerySealsAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignQuerySealsAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2EsignUtil esb2EsignUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2EsignQuerySealsAction start");
|
||||
|
||||
String pageIndex = String.valueOf(params.get("pageIndex"));
|
||||
String pageSize = String.valueOf(params.get("pageSize"));
|
||||
String organizeNo = String.valueOf(params.get("organizeNo"));
|
||||
// pageIndex=1&pageSize=10&organizeNo=91510115MA62QJQJ4N
|
||||
log.error("pageIndex:"+pageIndex);
|
||||
log.error("pageSize:"+pageSize);
|
||||
log.error("organizeNo:"+organizeNo);
|
||||
|
||||
String querySealsUrl = Constants.querySealsUrl+"?pageIndex="+pageIndex+"&pageSize="+pageSize+"&organizeNo="+organizeNo;
|
||||
log.error("querySealsUrl:{}",querySealsUrl);
|
||||
|
||||
String msg = queryEsignSealTemplate(querySealsUrl,organizeNo);
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg",msg);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
public String queryEsignSealTemplate(String querySealsUrl,String organizeNo){
|
||||
|
||||
// String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
// String xTimevaleProjectId = "1001003";
|
||||
// String eSignHost = "http://110.185.172.132:8086";
|
||||
|
||||
String bodyData = "";
|
||||
String xTimevaleSignature = esb2EsignUtil.encryptionHmacSHA256(bodyData);
|
||||
log.error("xTimevaleSignature:"+xTimevaleSignature);
|
||||
String msg = esb2EsignUtil.doGetEsignQuerySeals(xTimevaleSignature,querySealsUrl);
|
||||
log.error("msg:"+msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
// public String doHttpPost(String eSignHost,String eSignUrl,String bodyData,String xTimevaleSignature,String xTimevaleProjectId){
|
||||
// String msg = "";
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("text/plain");
|
||||
// System.out.println(eSignHost+eSignUrl);
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(eSignHost+eSignUrl)
|
||||
// .method("GET", null)
|
||||
// .addHeader("x-timevale-project-id", xTimevaleProjectId)
|
||||
// .addHeader("x-timevale-signature", xTimevaleSignature)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
// int code = response.code();
|
||||
// if(code == 200){
|
||||
// msg = response.body().string();
|
||||
// }
|
||||
// log.error("msg:"+msg);
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return msg;
|
||||
// }
|
||||
|
||||
public static void main(String[] args) {
|
||||
Esb2EsignQuerySealsAction esb2EsignQuerySealsAction = new Esb2EsignQuerySealsAction();
|
||||
String pageIndex = "1";
|
||||
String pageSize = "10";
|
||||
String organizeNo = "91510115MA62QJQJ4N";
|
||||
|
||||
String querySealsUrl = Constants.querySealsUrl+"?pageIndex="+pageIndex+"&pageSize="+pageSize+"&organizeNo="+organizeNo;
|
||||
esb2EsignQuerySealsAction.queryEsignSealTemplate(querySealsUrl,organizeNo);
|
||||
}
|
||||
|
||||
|
||||
// public String encryptionHmacSHA256(String secretKey,String bodyData){
|
||||
// String encryptionData = "";
|
||||
//// String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
// // 要签名的数据
|
||||
//// JSONObject dataObject = new JSONObject();
|
||||
//// dataObject.put("templateId","JMHT-ZXSJ");
|
||||
//// String data = "{\"templateId\":\"JMHT-ZXSJ\"}" ;
|
||||
// try {
|
||||
// // 初始化Mac对象
|
||||
// Mac sha256Hmac = Mac.getInstance("HmacSHA256");
|
||||
// SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
// sha256Hmac.init(secretKeySpec);
|
||||
// byte[] result = sha256Hmac.doFinal(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
// encryptionData = Hex.encodeHexString(result);
|
||||
// } catch (NoSuchAlgorithmException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }catch (InvalidKeyException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return encryptionData;
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.esign.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.esign.util.Esb2EsignUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2EsignSealsTemplateAction")
|
||||
public class Esb2EsignSealsTemplateAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignSealsTemplateAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2EsignUtil esb2EsignUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2EsignSealsTemplateAction start");
|
||||
|
||||
String templateId = (String) params.get("templateId");
|
||||
log.error("templateId:"+templateId);
|
||||
String msg = queryEsignSeals(templateId);
|
||||
log.error("msg:"+msg);
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg",msg);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
public String queryEsignSeals(String templateId){
|
||||
JSONObject dataObject = new JSONObject();
|
||||
// dataObject.put("templateId","JMHT-ZXSJ");
|
||||
dataObject.put("templateId",templateId);
|
||||
// String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
// String xTimevaleProjectId = "1001003";
|
||||
// String eSignHost = "http://110.185.172.132:8086";
|
||||
// String eSignSealsUrl = "/esignpro/rest/template/api/getTemplateInfo";
|
||||
|
||||
String bodyData = dataObject.toJSONString();
|
||||
log.error("bodyData:"+bodyData);
|
||||
String xTimevaleSignature = esb2EsignUtil.encryptionHmacSHA256(bodyData);
|
||||
log.error("xTimevaleSignature:"+xTimevaleSignature);
|
||||
String msg = esb2EsignUtil.doPostEsignSealsTemplate(bodyData,xTimevaleSignature);
|
||||
log.error("msg:"+msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
// public String doHttpPost(String eSignHost,String eSignUrl,String bodyData,String xTimevaleSignature,String xTimevaleProjectId){
|
||||
// String msg = "";
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json");
|
||||
// RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
// try {
|
||||
// Request request = new Request.Builder()
|
||||
// .url(eSignHost+eSignUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("x-timevale-project-id", xTimevaleProjectId)
|
||||
// .addHeader("x-timevale-signature", xTimevaleSignature)
|
||||
// .addHeader("Content-Type", "application/json")
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
// int code = response.code();
|
||||
// if(code == 200){
|
||||
// msg = response.body().string();
|
||||
// }
|
||||
// log.error("msg:"+msg);
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return msg;
|
||||
// }
|
||||
|
||||
public static void main(String[] args) {
|
||||
Esb2EsignSealsTemplateAction esb2EsignQuerySealsAction = new Esb2EsignSealsTemplateAction();
|
||||
esb2EsignQuerySealsAction.queryEsignSeals("JMHT-ZXSJ");
|
||||
}
|
||||
|
||||
|
||||
// public String encryptionHmacSHA256(String secretKey,String bodyData){
|
||||
// String encryptionData = "";
|
||||
//// String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
// // 要签名的数据
|
||||
//// JSONObject dataObject = new JSONObject();
|
||||
//// dataObject.put("templateId","JMHT-ZXSJ");
|
||||
//// String data = "{\"templateId\":\"JMHT-ZXSJ\"}" ;
|
||||
// try {
|
||||
// // 初始化Mac对象
|
||||
// Mac sha256Hmac = Mac.getInstance("HmacSHA256");
|
||||
// SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
// sha256Hmac.init(secretKeySpec);
|
||||
// byte[] result = sha256Hmac.doFinal(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
// encryptionData = Hex.encodeHexString(result);
|
||||
// } catch (NoSuchAlgorithmException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }catch (InvalidKeyException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return encryptionData;
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.esign.util;
|
||||
|
||||
import com.weaver.seconddev.chapanda.esign.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@Component
|
||||
public class Esb2EsignUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2EsignUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param xTimevaleSignature
|
||||
* @return
|
||||
*/
|
||||
public String doGetEsignQuerySeals(String xTimevaleSignature,String querySealsUrl){
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.eSignHost+querySealsUrl)
|
||||
.method("GET", null)
|
||||
.addHeader("x-timevale-project-id", Constants.xTimevaleProjectId)
|
||||
.addHeader("x-timevale-signature", xTimevaleSignature)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:"+code);
|
||||
if(code == 200){
|
||||
msg = response.body().string();
|
||||
log.error("msg:"+msg);
|
||||
}
|
||||
log.error("msg:"+msg);
|
||||
} catch (IOException e) {
|
||||
log.error("e:"+e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bodyData
|
||||
* @param xTimevaleSignature
|
||||
* @return
|
||||
*/
|
||||
public String doPostEsignSealsTemplate(String bodyData,String xTimevaleSignature){
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.eSignHost+Constants.queryTemplateUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("x-timevale-project-id", Constants.xTimevaleProjectId)
|
||||
.addHeader("x-timevale-signature", xTimevaleSignature)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
log.error("code:"+code);
|
||||
if(code == 200){
|
||||
msg = response.body().string();
|
||||
}
|
||||
log.error("msg:"+msg);
|
||||
} catch (IOException e) {
|
||||
log.error("e:"+e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param bodyData
|
||||
* @return
|
||||
*/
|
||||
public String encryptionHmacSHA256(String bodyData){
|
||||
String encryptionData = "";
|
||||
// String secretKey = "7f067a08f5c675137e6e72aa298e2c07";
|
||||
// 要签名的数据
|
||||
// JSONObject dataObject = new JSONObject();
|
||||
// dataObject.put("templateId","JMHT-ZXSJ");
|
||||
// String data = "{\"templateId\":\"JMHT-ZXSJ\"}" ;
|
||||
try {
|
||||
// 初始化Mac对象
|
||||
Mac sha256Hmac = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(Constants.secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
sha256Hmac.init(secretKeySpec);
|
||||
byte[] result = sha256Hmac.doFinal(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
encryptionData = Hex.encodeHexString(result);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}catch (InvalidKeyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return encryptionData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.cache;
|
||||
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.common.cache.base.ModuleCacheInterface;
|
||||
import com.weaver.common.cache.base.exception.IllegalCacheAccessException;
|
||||
import com.weaver.seconddev.chapanda.feishu.module.FeishuTokenModuleKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 集成缓存类
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
@Component
|
||||
public class FeishuTokenCacheKey implements ModuleCacheInterface {
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
public final static String FEISHU_TOKEN = "FEISHU_TOKEN";
|
||||
|
||||
@Override
|
||||
public void register() throws IllegalCacheAccessException, IllegalAccessException {
|
||||
baseCache.register(FeishuTokenModuleKey.FENSHUTOKEN_DATACENTER, this.getClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
public static String SysUserId = "1147262704872284161";
|
||||
|
||||
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 app_id = "cli_a8d0ee6b667dd00e";
|
||||
public static String app_secret = "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0";
|
||||
|
||||
public static String imageUrl = "/open-apis/im/v1/images";
|
||||
|
||||
public static String profileUrl = "/open-apis/contact/v3/users/";
|
||||
|
||||
public static String approvalCode = "5DB33242-4B8B-4D72-A64E-DF030E9D94EA";
|
||||
|
||||
public static String browser = "BROWSER";
|
||||
|
||||
public static boolean excludeStatistics = false ;
|
||||
|
||||
|
||||
public static String primaryUrl = "/open-apis/calendar/v4/calendars/primary?user_id_type=open_id";
|
||||
|
||||
|
||||
public static String calendarEventsUrl ="/open-apis/calendar/v4/calendars/%s/events?idempotency_key=%s&user_id_type=open_id";
|
||||
|
||||
public static String calendarAttendeesUrl = "/open-apis/calendar/v4/calendars/%s/events/%s/attendees?user_id_type=open_id";
|
||||
|
||||
|
||||
public static int color = -1 ;
|
||||
|
||||
public static boolean need_notification = true;
|
||||
|
||||
public static String visibility = "default";
|
||||
|
||||
public static String attendee_ability = "none";
|
||||
|
||||
public static String free_busy_status = "busy";
|
||||
|
||||
public static int minutes = 60;
|
||||
|
||||
public static String openIdUrl = "/open-apis/contact/v3/users/batch_get_id?user_id_type=open_id";
|
||||
|
||||
|
||||
public static String workflowApproveUrl = "/open-apis/approval/v4/external_instances" ;
|
||||
|
||||
public static String HrmHost = "https://hrtest.chabaidao.com";
|
||||
|
||||
public static String updateMode = "REPLACE";
|
||||
|
||||
public static String createTimeoffUrl = "/open-apis/calendar/v4/timeoff_events?user_id_type=open_id";
|
||||
|
||||
public static String timeZone = "Asia/Shanghai";
|
||||
|
||||
public static String deleteTimeoffUrl = "/open-apis/calendar/v4/timeoff_events/";
|
||||
|
||||
public static String cancelCalendarUrl = "/open-apis/calendar/v4/calendars/%s/events/%s";
|
||||
|
||||
public static boolean cancelNeedNotification = true;
|
||||
|
||||
public static String updateCalendarUrl ="/open-apis/calendar/v4/calendars/%s/events/%s?user_id_type=open_id";
|
||||
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.cost.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.cost.util.DatabaseUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class WorkflowDegreeLevelDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(WorkflowDegreeLevelDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> queryDegreeLevel(){
|
||||
String groupId = "weaver-workflow-report-serviceworkflowreport";
|
||||
String sourceType = "LOGIC";
|
||||
Map<String,Object> dataMap = new HashMap<String,Object>();
|
||||
try{
|
||||
String dataSql =" select custom_name,code " +
|
||||
" from wfp_customlevel " +
|
||||
" where delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
for(int i=0;i<recordList.size();i++){
|
||||
Map<String,Object> recordMap = recordList.get(i);
|
||||
String code = String.valueOf(recordMap.get("code"));
|
||||
String custom_name = String.valueOf(recordMap.get("custom_name"));
|
||||
dataMap.put(code,custom_name);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public Long queryEmployeeByCode(String staffcode){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
Long employeeId = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(staffcode)){
|
||||
String dataSql =" select id,username " +
|
||||
" from eteams.employee " +
|
||||
" where job_num = ? \n" +
|
||||
" and delete_type = 0 \n" +
|
||||
" and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(staffcode);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(!recordList.isEmpty()){
|
||||
employeeId = Long.parseLong(String.valueOf(recordList.get(0).get("id")));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendTodoUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuBotTodoAction")
|
||||
public class Esb2FeishuBotTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotTodoAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendTodoUtil esb2FeishuSendTodoUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String createTime = String.valueOf(params.get("createTime"));
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
if(createTime.contains("T")){
|
||||
createTime = createTime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String archivingTime = String.valueOf(params.get("archivingTime"));
|
||||
if("null".equals(archivingTime) || archivingTime == null){
|
||||
archivingTime = "";
|
||||
}
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String nodeName = String.valueOf(params.get("nodeName"));
|
||||
String degree = String.valueOf(params.get("degree"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("archivingTime:{}",archivingTime);
|
||||
log.error("nodeId:{}",nodeId);
|
||||
log.error("nodeName:{}",nodeName);
|
||||
log.error("degree:{}",degree);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
String creatorname = "";
|
||||
|
||||
String approvestatus = String.valueOf(params.get("approvestatus"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
|
||||
String sendtime = String.valueOf(params.get("sendtime"));
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
String recepttime = String.valueOf(params.get("recepttime"));
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
if(recepttime.contains("T")){
|
||||
recepttime = recepttime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
log.error("approvestatus:{}",approvestatus);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("sendtime:{}",sendtime);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
|
||||
String code = "";
|
||||
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
log.error("create_open_id:{}",create_open_id);
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(todoOpenIdList.size() > 0){
|
||||
|
||||
if("0".equals(msgType)){
|
||||
String status = "PENDING";
|
||||
code = esb2FeishuSendTodoUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
nodeId,nodeName,
|
||||
archivingTime,
|
||||
degree,mobileurl,pcurl,create_open_id,todoOpenIdList,
|
||||
recepttime,status
|
||||
);
|
||||
|
||||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else{
|
||||
log.error("create_open_id:{}","创建人手机号码为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("status",code);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
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.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuCalendarsCancelAction")
|
||||
public class Esb2FeishuCalendarsCancelAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarsCancelAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCancelCalendarUtil esb2FeishuCancelCalendarUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
String calendar_id = (String) params.get("calendar_id");
|
||||
String event_id = (String) params.get("event_id");
|
||||
|
||||
log.error("calendar_id:{}",calendar_id);
|
||||
log.error("event_id:{}",event_id);
|
||||
|
||||
if(StringUtils.isBlank(calendar_id)){
|
||||
return WeaResult.fail(500,"获取飞书的日历信息失败");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(event_id)){
|
||||
return WeaResult.fail(500,"获取飞书的日程信息失败");
|
||||
}
|
||||
|
||||
String code = "";
|
||||
if(StringUtils.isNotBlank(calendar_id) && StringUtils.isNotBlank(event_id)){
|
||||
code = esb2FeishuCancelCalendarUtil.cancelCalendarEvents(calendar_id,event_id);
|
||||
}
|
||||
log.error("code:{}",code);
|
||||
if(!"0".equals(code)){
|
||||
return WeaResult.fail(500,"飞书日程取消失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("calendarId",calendar_id);
|
||||
actionMap.put("eventId",event_id);
|
||||
actionMap.put("datacode",code);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuCalendarsEventsAction")
|
||||
public class Esb2FeishuCalendarsEventsAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarsEventsAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCalendarPrimaryUtil esb2FeishuCalendarPrimaryUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCalendarEventsUtil esb2FeishuCalendarEventsUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCalendarAttendeesUtil esb2FeishuCalendarAttendeesUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
String summary = (String) params.get("summary");
|
||||
String description = (String) params.get("description");
|
||||
String start_date = (String) params.get("start_date");
|
||||
String end_date = (String) params.get("end_date");
|
||||
String location_name = (String) params.get("location_name");
|
||||
String location_address = (String) params.get("location_address");
|
||||
String employee_id = (String) params.get("employee_id");
|
||||
String type = (String) params.get("type");
|
||||
String dataid = (String) params.get("dataid");
|
||||
|
||||
if("BusinessTrip".equals(type)){
|
||||
String start_time = "";
|
||||
if(params.containsKey("start_time")){
|
||||
start_time = String.valueOf(params.get("start_time"));
|
||||
}
|
||||
start_date = start_date+" "+start_time;
|
||||
String end_time = "";
|
||||
if(params.containsKey("end_time")){
|
||||
end_time = (String) params.get("end_time");
|
||||
}
|
||||
end_date = end_date+" "+end_time;
|
||||
}
|
||||
log.error("start_date:{}",start_date);
|
||||
log.error("end_date:{}",end_date);
|
||||
|
||||
String mobile = "";
|
||||
if(StringUtils.isNotBlank(employee_id)){
|
||||
Long employeeId = Long.parseLong(employee_id);
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
mobile = simpleEmployee.getMobile();
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(mobile)){
|
||||
return WeaResult.fail(500,"获取手机号为空");
|
||||
}
|
||||
|
||||
String openId = "";
|
||||
if(StringUtils.isNotBlank(mobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(mobile);
|
||||
if(userMap.containsKey(mobile)){
|
||||
openId = userMap.get(mobile).toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(openId)){
|
||||
return WeaResult.fail(500,"获取飞书的人员信息失败");
|
||||
}
|
||||
|
||||
log.error("Esb2FeishuCalendarsEventsAction start");
|
||||
log.error("openId:{}",openId);
|
||||
String attendee_id = "";
|
||||
String calendarId = esb2FeishuCalendarPrimaryUtil.queryUserCalendarPrimary();
|
||||
|
||||
if(StringUtils.isBlank(calendarId)){
|
||||
return WeaResult.fail(500,"获取飞书主日历失败");
|
||||
}
|
||||
|
||||
log.error("calendarId:{}",calendarId);
|
||||
String event_id = "";
|
||||
if(StringUtils.isNotBlank(calendarId)){
|
||||
event_id = esb2FeishuCalendarEventsUtil.createCalendarEvents(calendarId,summary,description,start_date,end_date,location_name,location_address);
|
||||
}
|
||||
log.error("event_id:{}",event_id);
|
||||
if(StringUtils.isBlank(event_id)){
|
||||
return WeaResult.fail(500,"创建飞书日历失败");
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(event_id)){
|
||||
attendee_id = esb2FeishuCalendarAttendeesUtil.sendUserCalendarEvents(openId,calendarId,event_id);
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(attendee_id)){
|
||||
return WeaResult.fail(500,"飞书日历增加人员失败");
|
||||
}
|
||||
|
||||
log.error("attendee_id:{}",attendee_id);
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("attendeeId",attendee_id);
|
||||
actionMap.put("calendarId",calendarId);
|
||||
actionMap.put("event_id",event_id);
|
||||
actionMap.put("openId",openId);
|
||||
actionMap.put("dataid",dataid);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
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.util.Esb2FeishuCalendarPrimaryUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuProfilePictureUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuCalendarsPrimaryAction")
|
||||
public class Esb2FeishuCalendarsPrimaryAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarsPrimaryAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCalendarPrimaryUtil esb2FeishuCalendarPrimaryUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuCalendarsPrimaryAction start");
|
||||
String calendarId = esb2FeishuCalendarPrimaryUtil.queryUserCalendarPrimary();
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2FeishuCalendarsPrimaryAction");
|
||||
actionMap.put("calendarId",calendarId);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
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.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuCalendarsUpdateAction")
|
||||
public class Esb2FeishuCalendarsUpdateAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarsUpdateAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCalendarUpdateUtil esb2FeishuCalendarUpdateUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
String summary = (String) params.get("summary");
|
||||
String description = (String) params.get("description");
|
||||
String start_date = (String) params.get("start_date");
|
||||
String end_date = (String) params.get("end_date");
|
||||
String location_name = (String) params.get("location_name");
|
||||
String location_address = (String) params.get("location_address");
|
||||
String type = (String) params.get("type");
|
||||
|
||||
String dataId = (String) params.get("dataId");
|
||||
|
||||
String openId = (String) params.get("openId");
|
||||
String calendarId = (String) params.get("calendarId");
|
||||
String eventId = (String) params.get("eventId");
|
||||
log.error("openId:{}",openId);
|
||||
log.error("calendarId:{}",calendarId);
|
||||
log.error("eventId:{}",eventId);
|
||||
log.error("dataId:{}",dataId);
|
||||
|
||||
if("BusinessTrip".equals(type)){
|
||||
String start_time = "";
|
||||
if(params.containsKey("start_time")){
|
||||
start_time = String.valueOf(params.get("start_time"));
|
||||
}
|
||||
start_date = start_date+" "+start_time;
|
||||
String end_time = "";
|
||||
if(params.containsKey("end_time")){
|
||||
end_time = (String) params.get("end_time");
|
||||
}
|
||||
end_date = end_date+" "+end_time;
|
||||
}
|
||||
log.error("start_date:{}",start_date);
|
||||
log.error("end_date:{}",end_date);
|
||||
|
||||
|
||||
if(StringUtils.isBlank(openId)){
|
||||
return WeaResult.fail(500,"获取飞书的人员信息失败");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(calendarId)){
|
||||
return WeaResult.fail(500,"获取飞书主日历失败");
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(eventId)){
|
||||
return WeaResult.fail(500,"获取飞书日历失败");
|
||||
}
|
||||
|
||||
String update_event_id = "";
|
||||
if(StringUtils.isNotBlank(calendarId) && StringUtils.isNotBlank(eventId)){
|
||||
update_event_id = esb2FeishuCalendarUpdateUtil.updateCalendarEvents(calendarId,eventId,summary,description,start_date,end_date,location_name,location_address);
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(update_event_id)){
|
||||
return WeaResult.fail(500,"更新飞书日历失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("calendarId",calendarId);
|
||||
actionMap.put("eventId",update_event_id);
|
||||
actionMap.put("openId",openId);
|
||||
actionMap.put("dataId",dataId);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.*;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuCreateCalendarsTimeoffAction")
|
||||
public class Esb2FeishuCreateCalendarsTimeoffAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCreateCalendarsTimeoffAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuCreateCalendarTimeoffUtil esb2FeishuCreateCalendarTimeoffUtil;
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
String title = (String) params.get("title");
|
||||
String description = (String) params.get("description");
|
||||
String start_date = (String) params.get("start_date");
|
||||
String end_date = (String) params.get("end_date");
|
||||
String employee_id = (String) params.get("employee_id");
|
||||
String type = (String) params.get("type");
|
||||
|
||||
log.error("start_date:{}",start_date);
|
||||
log.error("end_date:{}",end_date);
|
||||
|
||||
String mobile = "";
|
||||
if(StringUtils.isNotBlank(employee_id)){
|
||||
Long employeeId = Long.parseLong(employee_id);
|
||||
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(employeeId);
|
||||
mobile = simpleEmployee.getMobile();
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(mobile)){
|
||||
return WeaResult.fail(500,"获取手机号为空");
|
||||
}
|
||||
|
||||
String openId = "";
|
||||
if(StringUtils.isNotBlank(mobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(mobile);
|
||||
if(userMap.containsKey(mobile)){
|
||||
openId = userMap.get(mobile).toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(openId)){
|
||||
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);
|
||||
}
|
||||
log.error("timeoff_event_id:{}",timeoff_event_id);
|
||||
|
||||
if(StringUtils.isBlank(timeoff_event_id)){
|
||||
return WeaResult.fail(500,"请假日历创建失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("timeoffEventId",timeoff_event_id);
|
||||
actionMap.put("openId",openId);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
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.util.Esb2FeishuDeleteCalendarTimeoffUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuDeleteCalendarsTimeoffAction")
|
||||
public class Esb2FeishuDeleteCalendarsTimeoffAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuDeleteCalendarsTimeoffAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuDeleteCalendarTimeoffUtil esb2FeishuDeleteCalendarTimeoffUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
String timeoff_event_id = (String) params.get("timeoff_event_id");
|
||||
|
||||
log.error("timeoff_event_id:{}",timeoff_event_id);
|
||||
|
||||
if(StringUtils.isBlank(timeoff_event_id)){
|
||||
return WeaResult.fail(500,"获取请假日程为空");
|
||||
}
|
||||
|
||||
String code = "";
|
||||
if(StringUtils.isNotBlank(timeoff_event_id)){
|
||||
code = esb2FeishuDeleteCalendarTimeoffUtil.deleteCalendarTimeOff(timeoff_event_id);
|
||||
}
|
||||
log.error("code:{}",code);
|
||||
|
||||
if(!"0".equals(code)){
|
||||
return WeaResult.fail(500,"请假日历删除失败");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("timeoffEventId",timeoff_event_id);
|
||||
actionMap.put("datacode",code);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
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.util.Esb2FeishuProfilePictureUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendMessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuProfilePictureCardAction")
|
||||
public class Esb2FeishuProfilePictureCardAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuProfilePictureCardAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuProfilePictureUtil esb2FeishuProfilePictureUtil;
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuProfilePictureCardAction start");
|
||||
|
||||
Map<String, Object> dataMap = esb2FeishuProfilePictureUtil.updateProfilePicture();
|
||||
String chat_id = (String) dataMap.get("chat_id");
|
||||
String message_id = (String) dataMap.get("message_id");
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2FeishuProfilePictureCardAction");
|
||||
actionMap.put("chat_id",chat_id);
|
||||
actionMap.put("message_id",message_id);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendDeleteUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendDeleteAction")
|
||||
public class Esb2FeishuSendDeleteAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendDeleteAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendDeleteUtil esb2FeishuSendDeleteUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String createTime = String.valueOf(params.get("createTime"));
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
if(createTime.contains("T")){
|
||||
createTime = createTime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String archivingTime = String.valueOf(params.get("archivingTime"));
|
||||
if("null".equals(archivingTime) || archivingTime == null){
|
||||
archivingTime = "";
|
||||
}
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String nodeName = String.valueOf(params.get("nodeName"));
|
||||
String degree = String.valueOf(params.get("degree"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("archivingTime:{}",archivingTime);
|
||||
log.error("nodeId:{}",nodeId);
|
||||
log.error("nodeName:{}",nodeName);
|
||||
log.error("degree:{}",degree);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
|
||||
String approvestatus = String.valueOf(params.get("approvestatus"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
String recepttime = String.valueOf(params.get("recepttime"));
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
if(recepttime.contains("T")){
|
||||
recepttime = recepttime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
|
||||
log.error("approvestatus:{}",approvestatus);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String code = "";
|
||||
|
||||
String creatorname = "";
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
log.error("create_open_id:{}",create_open_id);
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(todoOpenIdList.size() >0){
|
||||
|
||||
if("2".equals(msgType)){
|
||||
|
||||
String status = "DELETED";
|
||||
code = esb2FeishuSendDeleteUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
nodeId,nodeName,
|
||||
archivingTime,
|
||||
degree,mobileurl,pcurl,create_open_id,todoOpenIdList,
|
||||
recepttime,status
|
||||
);
|
||||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else{
|
||||
log.error("create_open_id:{}","创建人手机号码为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("status",code);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendDoneUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendDoneAction")
|
||||
public class Esb2FeishuSendDoneAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendDoneAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendDoneUtil esb2FeishuSendDoneUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String createTime = String.valueOf(params.get("createTime"));
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
if(createTime.contains("T")){
|
||||
createTime = createTime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String archivingTime = String.valueOf(params.get("archivingTime"));
|
||||
if("null".equals(archivingTime) || archivingTime == null){
|
||||
archivingTime = "";
|
||||
}
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String nodeName = String.valueOf(params.get("nodeName"));
|
||||
String degree = String.valueOf(params.get("degree"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("archivingTime:{}",archivingTime);
|
||||
log.error("nodeId:{}",nodeId);
|
||||
log.error("nodeName:{}",nodeName);
|
||||
log.error("degree:{}",degree);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
String creatorname = "";
|
||||
String approvestatus = String.valueOf(params.get("approvestatus"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
|
||||
String sendtime = String.valueOf(params.get("sendtime"));
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
String recepttime = String.valueOf(params.get("recepttime"));
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
if(recepttime.contains("T")){
|
||||
recepttime = recepttime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
|
||||
log.error("approvestatus:{}",approvestatus);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("sendtime:{}",sendtime);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String code = "";
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
|
||||
String 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(create_open_id)){
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(todoOpenIdList.size()>0){
|
||||
|
||||
if("1".equals(msgType)){
|
||||
String status = "APPROVED";
|
||||
code = esb2FeishuSendDoneUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
nodeId,nodeName,
|
||||
archivingTime,
|
||||
degree,mobileurl,pcurl,create_open_id,todoOpenIdList,
|
||||
recepttime,status
|
||||
);
|
||||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else{
|
||||
log.error("create_open_id:{}","创建人手机号码为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("status",code);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendFinishUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendFinishAction")
|
||||
public class Esb2FeishuSendFinishAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendFinishAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendFinishUtil esb2FeishuSendFinishUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String createTime = String.valueOf(params.get("createTime"));
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
if(createTime.contains("T")){
|
||||
createTime = createTime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String archivingTime = String.valueOf(params.get("archivingTime"));
|
||||
if("null".equals(archivingTime) || archivingTime == null){
|
||||
archivingTime = "";
|
||||
}
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String nodeName = String.valueOf(params.get("nodeName"));
|
||||
String degree = String.valueOf(params.get("degree"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("archivingTime:{}",archivingTime);
|
||||
log.error("nodeId:{}",nodeId);
|
||||
log.error("nodeName:{}",nodeName);
|
||||
log.error("degree:{}",degree);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
String creatorname = "";
|
||||
String approvestatus = String.valueOf(params.get("approvestatus"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
|
||||
String sendtime = String.valueOf(params.get("sendtime"));
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
String recepttime = String.valueOf(params.get("recepttime"));
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
if(recepttime.contains("T")){
|
||||
recepttime = recepttime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
|
||||
log.error("approvestatus:{}",approvestatus);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("sendtime:{}",sendtime);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
|
||||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String code = "";
|
||||
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
log.error("create_open_id:{}",create_open_id);
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(todoOpenIdList.size() >0){
|
||||
|
||||
if("5".equals(msgType)){
|
||||
String status = "TERMINATED";
|
||||
code = esb2FeishuSendFinishUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
nodeId,nodeName,
|
||||
archivingTime,
|
||||
degree,mobileurl,pcurl,create_open_id,todoOpenIdList,
|
||||
recepttime,status
|
||||
);
|
||||
|
||||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else {
|
||||
log.error("create_open_id:{}","创建人手机号码为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("status",code);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
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.util.Esb2FeishuSendMessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendMessageCardAction")
|
||||
public class Esb2FeishuSendMessageCardAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendMessageCardAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendMessageUtil esb2FeishuSendMessageUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendMessageCardAction start");
|
||||
|
||||
// String feishuHost = "https://open.feishu.cn";
|
||||
// String tokenUrl = "/open-apis/auth/v3/tenant_access_token/internal";
|
||||
// String feishuUrl = "/open-apis/im/v1/messages?receive_id_type=open_id";
|
||||
// String app_id = "cli_a8d0ee6b667dd00e";
|
||||
// String app_secret = "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0";
|
||||
|
||||
// String template_id = "AAqIMF4quXR02" ;
|
||||
// String template_version_name = "1.0.1";
|
||||
// String receiveId = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
|
||||
String template_id = (String) params.get("template_id");
|
||||
String template_version_name = (String) params.get("template_version_name");
|
||||
String receiveId = (String) params.get("receiveId");
|
||||
log.error("template_id:{}",template_id);
|
||||
log.error("template_version_name:{}",template_version_name);
|
||||
log.error("receiveId:{}",receiveId);
|
||||
|
||||
Map<String, Object> dataMap = esb2FeishuSendMessageUtil.senCardMessage(template_id, template_version_name,receiveId);
|
||||
String chat_id = (String) dataMap.get("chat_id");
|
||||
String message_id = (String) dataMap.get("message_id");
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2FeishuSendMessageCardAction");
|
||||
actionMap.put("chat_id",chat_id);
|
||||
actionMap.put("message_id",message_id);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
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.util.Esb2FeishuSendMessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendMessageTxtAction")
|
||||
public class Esb2FeishuSendMessageTxtAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendMessageTxtAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendMessageUtil esb2FeishuSendMessageUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2FeishuSendMessageTxtAction start");
|
||||
|
||||
// String feishuHost = "https://open.feishu.cn";
|
||||
// String tokenUrl = "/open-apis/auth/v3/tenant_access_token/internal";
|
||||
// String feishuUrl = "/open-apis/im/v1/messages?receive_id_type=open_id";
|
||||
// String app_id = "cli_a8d0ee6b667dd00e";
|
||||
// String app_secret = "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0";
|
||||
|
||||
String content = (String) params.get("content");
|
||||
String receiveId = (String) params.get("receiveId");
|
||||
log.error("content:{}",content);
|
||||
log.error("receiveId:{}",receiveId);
|
||||
|
||||
// String content = "测试发送文本消息";
|
||||
// String receiveId = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
|
||||
Map<String, Object> dataMap = esb2FeishuSendMessageUtil.senTextMessage(content,receiveId);
|
||||
|
||||
String chat_id = (String) dataMap.get("chat_id");
|
||||
String message_id = (String) dataMap.get("message_id");
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2FeishuSendMessageTxtAction");
|
||||
actionMap.put("chat_id",chat_id);
|
||||
actionMap.put("message_id",message_id);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
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.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendTodoUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuSendTodoAction")
|
||||
public class Esb2FeishuSendTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendTodoAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuSendTodoUtil esb2FeishuSendTodoUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String createTime = String.valueOf(params.get("createTime"));
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
if(createTime.contains("T")){
|
||||
createTime = createTime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
String archivingTime = String.valueOf(params.get("archivingTime"));
|
||||
if("null".equals(archivingTime) || archivingTime == null){
|
||||
archivingTime = "";
|
||||
}
|
||||
String nodeId = String.valueOf(params.get("nodeId"));
|
||||
String nodeName = String.valueOf(params.get("nodeName"));
|
||||
String degree = String.valueOf(params.get("degree"));
|
||||
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("createTime:{}",createTime);
|
||||
log.error("requestName:{}",requestName);
|
||||
log.error("archivingTime:{}",archivingTime);
|
||||
log.error("nodeId:{}",nodeId);
|
||||
log.error("nodeName:{}",nodeName);
|
||||
log.error("degree:{}",degree);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
String creatorname = "";
|
||||
|
||||
String approvestatus = String.valueOf(params.get("approvestatus"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
|
||||
String sendtime = String.valueOf(params.get("sendtime"));
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
String recepttime = String.valueOf(params.get("recepttime"));
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
if(recepttime.contains("T")){
|
||||
recepttime = recepttime.replace("T"," ");
|
||||
}
|
||||
}
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
log.error("approvestatus:{}",approvestatus);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("sendtime:{}",sendtime);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
|
||||
String code = "";
|
||||
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
log.error("create_open_id:{}",create_open_id);
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(todoOpenIdList.size() > 0){
|
||||
|
||||
if("0".equals(msgType)){
|
||||
String status = "PENDING";
|
||||
code = esb2FeishuSendTodoUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
nodeId,nodeName,
|
||||
archivingTime,
|
||||
degree,mobileurl,pcurl,create_open_id,todoOpenIdList,
|
||||
recepttime,status
|
||||
);
|
||||
|
||||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else{
|
||||
log.error("create_open_id:{}","创建人手机号码为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("status",code);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.module;
|
||||
|
||||
/**
|
||||
* 缓存moduleKey
|
||||
*
|
||||
* @author wangj
|
||||
* @version 1.00版本
|
||||
* @Date 2025-6-3
|
||||
*/
|
||||
|
||||
public class FeishuTokenModuleKey {
|
||||
//datacenter
|
||||
public final static String FENSHUTOKEN_DATACENTER = "FENSHUTOKEN_DATACENTER";
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCalendarAttendeesUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarAttendeesUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String sendUserCalendarEvents(String user_id,String calendar_id,String event_id) {
|
||||
String attendee_id = "";
|
||||
Map<String, Object> messageMap = new HashMap<String, Object>();
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONArray attendeesArray = new JSONArray();
|
||||
JSONObject attendeesJson = new JSONObject();
|
||||
attendeesJson.put("type","user");
|
||||
attendeesJson.put("user_id",user_id);
|
||||
attendeesArray.add(attendeesJson);
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("attendees",attendeesArray);
|
||||
|
||||
log.error("bodyJson:"+bodyJson.toJSONString());
|
||||
|
||||
String calendarAttendeesUrl = String.format(Constants.calendarAttendeesUrl, calendar_id,event_id);
|
||||
log.error("calendarAttendeesUrl:"+calendarAttendeesUrl);
|
||||
|
||||
String message = doHttpPost(bodyJson.toJSONString(),token,calendarAttendeesUrl);
|
||||
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 attendeesList = dataJson.getJSONArray("attendees");
|
||||
for(int i=0;i<attendeesList.size();i++){
|
||||
JSONObject attendeeJson = attendeesList.getJSONObject(i);
|
||||
attendee_id = attendeeJson.getString("attendee_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attendee_id;
|
||||
}
|
||||
|
||||
public String doHttpPost(String bodyData,String token,String calendarAttendeesUrl){
|
||||
String msg = "";
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+calendarAttendeesUrl)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCalendarEventsUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarEventsUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String createCalendarEvents(String calendar_id,String summary,String description,
|
||||
String start_date,String end_date,String location_name,
|
||||
String location_address) {
|
||||
|
||||
String event_id = "";
|
||||
log.error("Esb2FeishuCalendarEventsUtil start");
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("summary",summary);
|
||||
bodyJson.put("description",description);
|
||||
bodyJson.put("need_notification",Constants.need_notification);
|
||||
|
||||
if(StringUtils.isNotBlank(start_date)){
|
||||
long startTime = convertTimeStamp(start_date);
|
||||
JSONObject startJson = new JSONObject();
|
||||
startJson.put("timestamp",String.valueOf(startTime));
|
||||
bodyJson.put("start_time",startJson);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(end_date)){
|
||||
long endTime = convertTimeStamp(end_date);
|
||||
JSONObject endJson = new JSONObject();
|
||||
endJson.put("timestamp",String.valueOf(endTime));
|
||||
bodyJson.put("end_time",endJson);
|
||||
}
|
||||
|
||||
bodyJson.put("visibility",Constants.visibility);
|
||||
bodyJson.put("attendee_ability",Constants.attendee_ability);
|
||||
bodyJson.put("free_busy_status",Constants.free_busy_status);
|
||||
|
||||
if(StringUtils.isNotBlank(location_name) && StringUtils.isNotBlank(location_address)){
|
||||
JSONObject locationJson = new JSONObject();
|
||||
locationJson.put("name",location_name);
|
||||
locationJson.put("address",location_address);
|
||||
bodyJson.put("location",locationJson);
|
||||
}
|
||||
|
||||
|
||||
bodyJson.put("color",Constants.color);
|
||||
JSONArray remindersArray = new JSONArray();
|
||||
JSONObject remindersJson = new JSONObject();
|
||||
remindersJson.put("minutes",Constants.minutes);
|
||||
remindersArray.add(remindersJson);
|
||||
bodyJson.put("reminders",remindersArray);
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
// https://open.feishu.cn/open-apis/calendar/v4/calendars/feishu.cn_fTzelMMvbKeK8koiHl3uFf@group.calendar.feishu.cn/events?idempotency_key=42a0f05f7c274e07bec07a47841968f5&user_id_type=open_id
|
||||
String calendarEventsUrl = String.format(Constants.calendarEventsUrl, calendar_id,uuid);
|
||||
log.error("calendarEventsUrl:{}",calendarEventsUrl);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
String message = doHttpPost(bodyJson.toJSONString(),token,calendarEventsUrl);
|
||||
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");
|
||||
JSONObject eventJson = dataJson.getJSONObject("event");
|
||||
if(eventJson.containsKey("event_id")){
|
||||
event_id = eventJson.getString("event_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return event_id;
|
||||
}
|
||||
|
||||
public String doHttpPost(String bodyData,String token,String calendarEventsUrl){
|
||||
String msg = "";
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+calendarEventsUrl)
|
||||
.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 long convertTimeStamp(String date) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println(date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
|
||||
System.out.println(date);
|
||||
System.out.println(date.length());
|
||||
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime() / 1000 ;
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println(timestamp);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String date = "2025-07-18 09:00";
|
||||
System.out.println(date.length());
|
||||
Esb2FeishuCalendarEventsUtil Esb2FeishuCalendarEventsUtil = new Esb2FeishuCalendarEventsUtil();
|
||||
Esb2FeishuCalendarEventsUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCalendarPrimaryUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarPrimaryUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String queryUserCalendarPrimary() {
|
||||
String calendar_id = "";
|
||||
log.error("Esb2FeishuGetCalendarPrimaryUtil start");
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String message = doHttpPost(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 calendarsArray = dataJson.getJSONArray("calendars");
|
||||
for(int i=0;i<calendarsArray.size();i++){
|
||||
JSONObject calendarJson = calendarsArray.getJSONObject(i);
|
||||
|
||||
if(calendarJson.containsKey("calendar")){
|
||||
JSONObject calendarObject = calendarJson.getJSONObject("calendar");
|
||||
String type = calendarObject.getString("type");
|
||||
if("primary".equals(type)){
|
||||
calendar_id = calendarObject.getString("calendar_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return calendar_id;
|
||||
}
|
||||
|
||||
public String doHttpPost(String token){
|
||||
String msg = "";
|
||||
|
||||
// https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id
|
||||
// t-g1046ofDRKNCIEO3YKB42MQCDBZCYZGWAROROPGJ
|
||||
// bodyData = "{\n \"receive_id\": \"ou_f2ee4ea6545e537c426fa058c31bab88\",\n \"msg_type\": \"interactive\",\n \"content\": \"{\\\"type\\\":\\\"template\\\",\\\"data\\\":{\\\"template_id\\\":\\\"AAqIMF4quXR02\\\",\\\"template_version_name\\\":\\\"1.0.1\\\",\\\"template_variable\\\":{\\\"name\\\":\\\"王文猛\\\",\\\"current_date\\\":\\\"06-24\\\"}}}\"\n}" ;
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, "{}");
|
||||
log.error("primaryUrl:{}",Constants.feishuHost+Constants.primaryUrl);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.primaryUrl)
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCalendarUpdateUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCalendarUpdateUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String updateCalendarEvents(String calendar_id,String event_id,String summary,String description,
|
||||
String start_date,String end_date,String location_name,
|
||||
String location_address) {
|
||||
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("summary",summary);
|
||||
bodyJson.put("description",description);
|
||||
bodyJson.put("need_notification",Constants.need_notification);
|
||||
|
||||
if(StringUtils.isNotBlank(start_date)){
|
||||
long startTime = convertTimeStamp(start_date);
|
||||
JSONObject startJson = new JSONObject();
|
||||
startJson.put("timestamp",String.valueOf(startTime));
|
||||
bodyJson.put("start_time",startJson);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(end_date)){
|
||||
long endTime = convertTimeStamp(end_date);
|
||||
JSONObject endJson = new JSONObject();
|
||||
endJson.put("timestamp",String.valueOf(endTime));
|
||||
bodyJson.put("end_time",endJson);
|
||||
}
|
||||
|
||||
bodyJson.put("visibility",Constants.visibility);
|
||||
bodyJson.put("attendee_ability",Constants.attendee_ability);
|
||||
bodyJson.put("free_busy_status",Constants.free_busy_status);
|
||||
|
||||
if(StringUtils.isNotBlank(location_name) && StringUtils.isNotBlank(location_address)){
|
||||
JSONObject locationJson = new JSONObject();
|
||||
locationJson.put("name",location_name);
|
||||
locationJson.put("address",location_address);
|
||||
bodyJson.put("location",locationJson);
|
||||
}
|
||||
|
||||
bodyJson.put("color",Constants.color);
|
||||
JSONArray remindersArray = new JSONArray();
|
||||
JSONObject remindersJson = new JSONObject();
|
||||
remindersJson.put("minutes",Constants.minutes);
|
||||
remindersArray.add(remindersJson);
|
||||
bodyJson.put("reminders",remindersArray);
|
||||
|
||||
String updateCalendarUrl = String.format(Constants.updateCalendarUrl, calendar_id,event_id);
|
||||
log.error("updateCalendarUrl:{}",updateCalendarUrl);
|
||||
log.error("bodyJson:{}",bodyJson.toJSONString());
|
||||
|
||||
String message = doHttpPost(bodyJson.toJSONString(),token,updateCalendarUrl);
|
||||
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");
|
||||
JSONObject eventJson = dataJson.getJSONObject("event");
|
||||
if(eventJson.containsKey("event_id")){
|
||||
event_id = eventJson.getString("event_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return event_id;
|
||||
}
|
||||
|
||||
public String doHttpPost(String bodyData,String token,String updateCalendarUrl){
|
||||
String msg = "";
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+updateCalendarUrl)
|
||||
.method("PATCH", 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 long convertTimeStamp(String date) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println(date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
|
||||
System.out.println(date);
|
||||
System.out.println(date.length());
|
||||
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime() / 1000 ;
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println(timestamp);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String date = "2025-07-18 09:00";
|
||||
System.out.println(date.length());
|
||||
Esb2FeishuCalendarUpdateUtil Esb2FeishuCalendarEventsUtil = new Esb2FeishuCalendarUpdateUtil();
|
||||
Esb2FeishuCalendarEventsUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCancelCalendarUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCancelCalendarUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String cancelCalendarEvents(String calendar_id,String event_id) {
|
||||
log.error("Esb2FeishuGetCalendarPrimaryUtil start");
|
||||
String code = "";
|
||||
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);
|
||||
|
||||
String message = doHttpPost(token,cancelCalendarUrl);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
code = returnData.getString("code");
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public String doHttpPost(String token,String cancelCalendarUrl){
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
// "/open-apis/calendar/v4/calendars/feishu.cn_CyZB7DD34hJrcBwosRTtDf@group.calendar.feishu.cn/events/e4bf3b18-0b6d-7037-0ae3-0ad7604b30da_0?need_notification=true"
|
||||
RequestBody body = RequestBody.create(mediaType, "");
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+cancelCalendarUrl)
|
||||
.method("DELETE", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuCreateCalendarTimeoffUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuCreateCalendarTimeoffUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String createCalendarTimeOff(String user_open_id,String summary,String description,
|
||||
String start_date,String end_date,String type) {
|
||||
|
||||
String timeoff_event_id = "";
|
||||
log.error("Esb2FeishuCalendarEventsUtil start");
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("user_id",user_open_id);
|
||||
bodyJson.put("title",summary);
|
||||
bodyJson.put("description",description);
|
||||
bodyJson.put("timezone",Constants.timeZone);
|
||||
if("timestamp".equals(type)){
|
||||
long startTime = convertTimeStamp(start_date);
|
||||
long endTime = convertTimeStamp(end_date);
|
||||
bodyJson.put("start_time",String.valueOf(startTime));
|
||||
bodyJson.put("end_time",String.valueOf(endTime));
|
||||
}else{
|
||||
bodyJson.put("start_time",start_date);
|
||||
bodyJson.put("end_time",end_date);
|
||||
}
|
||||
|
||||
String message = doHttpPost(bodyJson.toJSONString(),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");
|
||||
if(dataJson.containsKey("timeoff_event_id")){
|
||||
timeoff_event_id = dataJson.getString("timeoff_event_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return timeoff_event_id;
|
||||
}
|
||||
|
||||
|
||||
public String doHttpPost(String bodyData,String token){
|
||||
String msg = "";
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
|
||||
// RequestBody body = RequestBody.create(mediaType, "{\n \"user_id\":\"ou_8ff7816cfa8cda57643cac2a06fbdc7e\",\n \"timezone\":\"Asia/Shanghai\",\n \"start_time\":\"2026-07-26\",\n \"end_time\":\"2026-07-27\",\n \"title\":\"石磊请假流程-2026-06-19\",\n \"description\":\"石磊请假流程\"\n}");
|
||||
|
||||
try {
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.createTimeoffUrl)
|
||||
.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 long convertTimeStamp(String date) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println(date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
|
||||
System.out.println(date);
|
||||
System.out.println(date.length());
|
||||
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime() / 1000 ;
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
System.out.println(timestamp);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String date = "2025-07-18 09:00";
|
||||
System.out.println(date.length());
|
||||
Esb2FeishuCreateCalendarTimeoffUtil Esb2FeishuCalendarEventsUtil = new Esb2FeishuCreateCalendarTimeoffUtil();
|
||||
Esb2FeishuCalendarEventsUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuDeleteCalendarTimeoffUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuDeleteCalendarTimeoffUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String deleteCalendarTimeOff(String timeoff_event_id) {
|
||||
|
||||
String code = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
String message = doHttpPost(timeoff_event_id,token);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
code = returnData.getString("code");
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public String doHttpPost(String timeoff_event_id,String token){
|
||||
String msg = "";
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
// MediaType mediaType = MediaType.parse("text/plain");
|
||||
// RequestBody body = RequestBody.create(mediaType, "");
|
||||
try {
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.deleteTimeoffUrl+timeoff_event_id)
|
||||
.method("DELETE", null)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuOpenIdUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuOpenIdUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public Map<String, Object> queryFeishuOpenIdByMobiles(String mobile) {
|
||||
log.error("queryFeishuOpenIdByMobiles start");
|
||||
Map<String, Object> userMap = new HashMap<String, Object>();
|
||||
String searchType = "mobiles";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
List<String> mobiles = new ArrayList<String>();
|
||||
mobiles.add(mobile);
|
||||
|
||||
String message = doHttpPost(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");
|
||||
}
|
||||
|
||||
log.error("user_id:{}",user_id);
|
||||
userMap.put(mobile,user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param email
|
||||
* @param calendar_id
|
||||
* @param event_id
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> queryFeishuOpenIdByEmails(String email,String calendar_id,String event_id) {
|
||||
log.error("queryFeishuOpenIdByEmails start");
|
||||
String searchType = "emails";
|
||||
Map<String, Object> userMap = new HashMap<String, Object>();
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
List<String> emails = new ArrayList<String>();
|
||||
emails.add(email);
|
||||
String message = doHttpPost(emails,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_mobile = userJson.getString("mobile");
|
||||
String user_id = userJson.getString("user_id");
|
||||
userMap.put(user_mobile,user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userMap;
|
||||
}
|
||||
|
||||
|
||||
public String doHttpPost(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.openIdUrl)
|
||||
.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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuProfilePictureUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuProfilePictureUtil.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuUploadImageUtil esb2FeishuUploadImageUtil;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
public Map<String, Object> updateProfilePicture() {
|
||||
log.error("senCardMessage start");
|
||||
|
||||
String openId = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String avatarKey = esb2FeishuUploadImageUtil.uploadImage();
|
||||
|
||||
Map<String, Object> messageMap = new HashMap<String, Object>();
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("avatar_key",avatarKey);
|
||||
System.out.println("bodyJson,"+bodyJson.toJSONString());
|
||||
String message= updateProfilePictureByToken(bodyJson.toJSONString(),openId,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");
|
||||
String chat_id = dataJson.getString("chat_id");
|
||||
String msg_type = dataJson.getString("msg_type");
|
||||
String message_id = dataJson.getString("message_id");
|
||||
String create_time = dataJson.getString("create_time");
|
||||
|
||||
messageMap.put("chat_id",chat_id);
|
||||
messageMap.put("msg_type",msg_type);
|
||||
messageMap.put("message_id",message_id);
|
||||
messageMap.put("create_time",create_time);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return messageMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public String updateProfilePictureByToken(String avatar_key,String open_id,String token){
|
||||
String msg = "";
|
||||
log.error("avatar_key:{}",avatar_key);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject bodyData = new JSONObject();
|
||||
bodyData.put("avatar_key",avatar_key);
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData.toJSONString());
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.profileUrl+"/"+open_id+"?user_id_type=open_id")
|
||||
.method("PATCH", 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 static void main(String[] args) {
|
||||
|
||||
Esb2FeishuProfilePictureUtil esb2FeishuSendMessageUtil = new Esb2FeishuProfilePictureUtil();
|
||||
esb2FeishuSendMessageUtil.updateProfilePicture();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,393 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
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 okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuSendDeleteUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendDeleteUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private WorkflowDegreeLevelDao workflowDegreeLevelDao;
|
||||
|
||||
public String 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,List<String> todoOpenIdList,
|
||||
String recepttime,String status
|
||||
) {
|
||||
log.error("senTodoMessage start");
|
||||
String code = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String createTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
createTimeStamp = String.valueOf(convertTimeStamp(createTime));
|
||||
}
|
||||
|
||||
String archivingTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(archivingTime)){
|
||||
archivingTimeStamp = String.valueOf(convertTimeStamp(archivingTime));
|
||||
}
|
||||
String receptTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
receptTimeStamp = String.valueOf(convertTimeStamp(recepttime));
|
||||
}
|
||||
|
||||
log.error("createTimeStamp:{}",createTimeStamp);
|
||||
log.error("archivingTimeStamp:{}",archivingTimeStamp);
|
||||
log.error("receptTimeStamp:{}",receptTimeStamp);
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
if(StringUtils.isNotBlank(creatorName)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value",creatorName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(degree)){
|
||||
Map<String,Object> degreeMap = workflowDegreeLevelDao.queryDegreeLevel();
|
||||
if(degreeMap.containsKey(degree)){
|
||||
String degreeName = String.valueOf(degreeMap.get(degree));
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value",degreeName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(requestmark)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","流程编号");
|
||||
formMap.put("value",requestmark);
|
||||
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","接收时间");
|
||||
formMap.put("value",recepttime);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
String bodyData = appendBodyParam(requestid,requestName,create_open_id,
|
||||
department_id,department_name,
|
||||
createTimeStamp,archivingTimeStamp,
|
||||
formList,nodeId,nodeName,todoOpenIdList,
|
||||
mobileurl, pcurl,receptTimeStamp,status);
|
||||
|
||||
log.error("feishu-delete:{}",bodyData);
|
||||
|
||||
String message = doPostSendMessage(bodyData,token);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
code = returnData.getString("code");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
public String doPostSendMessage(String bodyData,
|
||||
String token){
|
||||
String msg = "";
|
||||
|
||||
// "{\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()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.workflowApproveUrl)
|
||||
.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 appendBodyParam(String requestid,
|
||||
String requestName,
|
||||
String create_open_id,
|
||||
String department_id,
|
||||
String department_name,
|
||||
String createTimeStamp,
|
||||
String archivingTimeStamp,
|
||||
List<Map<String, Object>> formList,
|
||||
String node_id,
|
||||
String nodeName,
|
||||
List<String> todoOpenIdList,
|
||||
String mobileurl,
|
||||
String pcurl,
|
||||
String receptTimeStamp,
|
||||
String status
|
||||
){
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("approval_code",Constants.approvalCode);
|
||||
bodyJson.put("status",status);
|
||||
// JSONObject extraJson = new JSONObject();
|
||||
// extraJson.put("测试","测试");
|
||||
// bodyJson.put("extra",extraJson.toJSONString());
|
||||
bodyJson.put("instance_id",requestid);
|
||||
JSONObject linksJson = new JSONObject();
|
||||
linksJson.put("pc_link",Constants.HrmHost+pcurl);
|
||||
linksJson.put("mobile_link",Constants.HrmHost+mobileurl);
|
||||
bodyJson.put("links",linksJson);
|
||||
bodyJson.put("title","@i18n@title");
|
||||
|
||||
|
||||
// bodyJson.put("user_id",Constants.SysUserId);
|
||||
// bodyJson.put("user_name","@i18n@9");
|
||||
bodyJson.put("open_id",create_open_id);
|
||||
// bodyJson.put("department_id",department_id);
|
||||
|
||||
bodyJson.put("start_time",createTimeStamp);
|
||||
bodyJson.put("end_time",archivingTimeStamp);
|
||||
bodyJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
bodyJson.put("display_method",Constants.browser);
|
||||
bodyJson.put("update_mode",Constants.updateMode);
|
||||
|
||||
log.error("update_time:{}",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
JSONArray taskListArray = new JSONArray();
|
||||
for(int i=0;i<todoOpenIdList.size();i++){
|
||||
String task_open_id = String.valueOf(todoOpenIdList.get(i));
|
||||
log.error("task_open_id:"+task_open_id);
|
||||
JSONObject taskListJson = new JSONObject();
|
||||
taskListJson.put("task_id","weaver_"+requestid+"_"+task_open_id);
|
||||
taskListJson.put("open_id",task_open_id);
|
||||
taskListJson.put("title","@i18n@title");
|
||||
taskListJson.put("links",linksJson);
|
||||
taskListJson.put("status",status);
|
||||
taskListJson.put("create_time",receptTimeStamp);
|
||||
|
||||
taskListJson.put("end_time",archivingTimeStamp);
|
||||
taskListJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
taskListJson.put("display_method",Constants.browser);
|
||||
taskListJson.put("exclude_statistics",Constants.excludeStatistics);
|
||||
|
||||
// JSONArray actionConfigsArray = new JSONArray();
|
||||
// JSONObject actionConfigsJson = new JSONObject();
|
||||
// actionConfigsJson.put("action_type","APPROVE");
|
||||
// actionConfigsJson.put("action_name","@i18n@5");
|
||||
// actionConfigsJson.put("is_need_reason",false);
|
||||
// actionConfigsJson.put("is_need_approve_reason",false);
|
||||
// actionConfigsJson.put("is_need_comment",false);
|
||||
// actionConfigsArray.add(actionConfigsJson);
|
||||
// taskListJson.put("action_configs",actionConfigsArray);
|
||||
|
||||
taskListJson.put("node_id",node_id);
|
||||
taskListJson.put("node_name","@i18n@node");
|
||||
taskListArray.add(taskListJson);
|
||||
}
|
||||
|
||||
bodyJson.put("task_list",taskListArray);
|
||||
|
||||
|
||||
JSONArray i18nResourcesTextsArray = new JSONArray();
|
||||
|
||||
JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@title");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@node");
|
||||
i18nResourcesTextsJson.put("value",nodeName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
if(StringUtils.isNotBlank(department_id)){
|
||||
bodyJson.put("department_id",department_id);
|
||||
}else if(StringUtils.isNotBlank(department_name)){
|
||||
String key = "@i18n@departmentname";
|
||||
bodyJson.put("department_name",key);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key);
|
||||
i18nResourcesTextsJson.put("value",department_name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
|
||||
JSONArray formArray = new JSONArray();
|
||||
for(int i=0;i<formList.size();i++){
|
||||
Map<String,Object> formMap = formList.get(i);
|
||||
String name = formMap.get("name").toString();
|
||||
String value = formMap.get("value").toString();
|
||||
|
||||
String key_key = "@i18n@k"+i;
|
||||
String val_key = "@i18n@v"+i;
|
||||
|
||||
JSONObject formJson = new JSONObject();
|
||||
formJson.put("name",key_key);
|
||||
formJson.put("value",val_key);
|
||||
formArray.add(formJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key_key);
|
||||
i18nResourcesTextsJson.put("value",name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",val_key);
|
||||
i18nResourcesTextsJson.put("value",value);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
bodyJson.put("form",formArray);
|
||||
|
||||
// Iterator<Map.Entry<String, Object>> entries = textsMap.entrySet().iterator();
|
||||
// while (entries.hasNext()) {
|
||||
// Map.Entry<String, Object> entry = entries.next();
|
||||
// String key = entry.getKey();
|
||||
// String value = String.valueOf(entry.getValue());
|
||||
// JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
// i18nResourcesTextsJson.put("key",key);
|
||||
// i18nResourcesTextsJson.put("value",value);
|
||||
// i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
// }
|
||||
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsArray);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
return bodyJson.toJSONString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Esb2FeishuSendDeleteUtil esb2FeishuSendTodoUtil = new Esb2FeishuSendDeleteUtil();
|
||||
|
||||
String requestid = "1154744413522714631";
|
||||
String requestName = "督导奖励申请流程-石磊-2025-07-09";
|
||||
|
||||
String create_open_id = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String start_time = String.valueOf(System.currentTimeMillis());
|
||||
String end_time = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
Map<String, Object> textsMap = new HashMap<String,Object>();
|
||||
|
||||
List<Map<String, Object>> taskList = new ArrayList<Map<String, Object>>();
|
||||
Map<String,Object> taskMap = new HashMap<String,Object>();
|
||||
taskMap.put("open_id",create_open_id);
|
||||
taskList.add(taskMap);
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value","石磊");
|
||||
formList.add(formMap);
|
||||
formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value","紧急");
|
||||
formList.add(formMap);
|
||||
String node_id = "1151724772346716177";
|
||||
String nodeName = "1级审批";
|
||||
|
||||
// String data = esb2FeishuSendTodoUtil.appendBodyParam(requestid,
|
||||
// requestName,create_open_id,department_id,department_name,start_time,end_time,
|
||||
// formList,node_id,nodeName,new ArrayList<String>(),"","","");
|
||||
// System.out.println(data);
|
||||
|
||||
String date = "2025-07-17 21:07:48";
|
||||
|
||||
esb2FeishuSendTodoUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
|
||||
public long convertTimeStamp(String date) {
|
||||
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
if(date.contains("T")){
|
||||
date = date.replace("T"," ");
|
||||
}
|
||||
}
|
||||
System.out.println("date:"+date);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println("date:"+date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime();
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
log.error("timestamp:{}",timestamp);
|
||||
System.out.println(timestamp);
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,393 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
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 okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuSendDoneUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendDoneUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private WorkflowDegreeLevelDao workflowDegreeLevelDao;
|
||||
|
||||
public String 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,List<String> todoOpenIdList,
|
||||
String recepttime,String status
|
||||
) {
|
||||
log.error("senTodoMessage start");
|
||||
String code = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String createTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
createTimeStamp = String.valueOf(convertTimeStamp(createTime));
|
||||
}
|
||||
|
||||
String archivingTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(archivingTime)){
|
||||
archivingTimeStamp = String.valueOf(convertTimeStamp(archivingTime));
|
||||
}
|
||||
String receptTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
receptTimeStamp = String.valueOf(convertTimeStamp(recepttime));
|
||||
}
|
||||
|
||||
log.error("createTimeStamp:{}",createTimeStamp);
|
||||
log.error("archivingTimeStamp:{}",archivingTimeStamp);
|
||||
log.error("receptTimeStamp:{}",receptTimeStamp);
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
if(StringUtils.isNotBlank(creatorName)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value",creatorName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(degree)){
|
||||
Map<String,Object> degreeMap = workflowDegreeLevelDao.queryDegreeLevel();
|
||||
if(degreeMap.containsKey(degree)){
|
||||
String degreeName = String.valueOf(degreeMap.get(degree));
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value",degreeName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(requestmark)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","流程编号");
|
||||
formMap.put("value",requestmark);
|
||||
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","接收时间");
|
||||
formMap.put("value",recepttime);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
String bodyData = appendBodyParam(requestid,requestName,create_open_id,
|
||||
department_id,department_name,
|
||||
createTimeStamp,archivingTimeStamp,
|
||||
formList,nodeId,nodeName,todoOpenIdList,
|
||||
mobileurl, pcurl,receptTimeStamp,status);
|
||||
|
||||
log.error("feishu-done:{}",bodyData);
|
||||
|
||||
String message = doPostSendMessage(bodyData,token);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
code = returnData.getString("code");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
public String doPostSendMessage(String bodyData,
|
||||
String token){
|
||||
String msg = "";
|
||||
|
||||
// "{\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()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.workflowApproveUrl)
|
||||
.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 appendBodyParam(String requestid,
|
||||
String requestName,
|
||||
String create_open_id,
|
||||
String department_id,
|
||||
String department_name,
|
||||
String createTimeStamp,
|
||||
String archivingTimeStamp,
|
||||
List<Map<String, Object>> formList,
|
||||
String node_id,
|
||||
String nodeName,
|
||||
List<String> todoOpenIdList,
|
||||
String mobileurl,
|
||||
String pcurl,
|
||||
String receptTimeStamp,
|
||||
String status
|
||||
){
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("approval_code",Constants.approvalCode);
|
||||
bodyJson.put("status",status);
|
||||
// JSONObject extraJson = new JSONObject();
|
||||
// extraJson.put("测试","测试");
|
||||
// bodyJson.put("extra",extraJson.toJSONString());
|
||||
bodyJson.put("instance_id",requestid);
|
||||
JSONObject linksJson = new JSONObject();
|
||||
linksJson.put("pc_link",Constants.HrmHost+pcurl);
|
||||
linksJson.put("mobile_link",Constants.HrmHost+mobileurl);
|
||||
bodyJson.put("links",linksJson);
|
||||
bodyJson.put("title","@i18n@title");
|
||||
|
||||
|
||||
// bodyJson.put("user_id",Constants.SysUserId);
|
||||
// bodyJson.put("user_name","@i18n@9");
|
||||
bodyJson.put("open_id",create_open_id);
|
||||
// bodyJson.put("department_id",department_id);
|
||||
|
||||
bodyJson.put("start_time",createTimeStamp);
|
||||
bodyJson.put("end_time",archivingTimeStamp);
|
||||
bodyJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
bodyJson.put("display_method",Constants.browser);
|
||||
bodyJson.put("update_mode",Constants.updateMode);
|
||||
|
||||
log.error("update_time:{}",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
JSONArray taskListArray = new JSONArray();
|
||||
for(int i=0;i<todoOpenIdList.size();i++){
|
||||
String task_open_id = String.valueOf(todoOpenIdList.get(i));
|
||||
log.error("task_open_id:"+task_open_id);
|
||||
JSONObject taskListJson = new JSONObject();
|
||||
taskListJson.put("task_id","weaver_"+requestid+"_"+task_open_id);
|
||||
taskListJson.put("open_id",task_open_id);
|
||||
taskListJson.put("title","@i18n@title");
|
||||
taskListJson.put("links",linksJson);
|
||||
taskListJson.put("status",status);
|
||||
taskListJson.put("create_time",receptTimeStamp);
|
||||
|
||||
taskListJson.put("end_time",archivingTimeStamp);
|
||||
taskListJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
taskListJson.put("display_method",Constants.browser);
|
||||
taskListJson.put("exclude_statistics",Constants.excludeStatistics);
|
||||
|
||||
// JSONArray actionConfigsArray = new JSONArray();
|
||||
// JSONObject actionConfigsJson = new JSONObject();
|
||||
// actionConfigsJson.put("action_type","APPROVE");
|
||||
// actionConfigsJson.put("action_name","@i18n@5");
|
||||
// actionConfigsJson.put("is_need_reason",false);
|
||||
// actionConfigsJson.put("is_need_approve_reason",false);
|
||||
// actionConfigsJson.put("is_need_comment",false);
|
||||
// actionConfigsArray.add(actionConfigsJson);
|
||||
// taskListJson.put("action_configs",actionConfigsArray);
|
||||
|
||||
taskListJson.put("node_id",node_id);
|
||||
taskListJson.put("node_name","@i18n@node");
|
||||
taskListArray.add(taskListJson);
|
||||
}
|
||||
|
||||
bodyJson.put("task_list",taskListArray);
|
||||
|
||||
|
||||
JSONArray i18nResourcesTextsArray = new JSONArray();
|
||||
|
||||
JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@title");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@node");
|
||||
i18nResourcesTextsJson.put("value",nodeName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
if(StringUtils.isNotBlank(department_id)){
|
||||
bodyJson.put("department_id",department_id);
|
||||
}else if(StringUtils.isNotBlank(department_name)){
|
||||
String key = "@i18n@departmentname";
|
||||
bodyJson.put("department_name",key);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key);
|
||||
i18nResourcesTextsJson.put("value",department_name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
|
||||
JSONArray formArray = new JSONArray();
|
||||
for(int i=0;i<formList.size();i++){
|
||||
Map<String,Object> formMap = formList.get(i);
|
||||
String name = formMap.get("name").toString();
|
||||
String value = formMap.get("value").toString();
|
||||
|
||||
String key_key = "@i18n@k"+i;
|
||||
String val_key = "@i18n@v"+i;
|
||||
|
||||
JSONObject formJson = new JSONObject();
|
||||
formJson.put("name",key_key);
|
||||
formJson.put("value",val_key);
|
||||
formArray.add(formJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key_key);
|
||||
i18nResourcesTextsJson.put("value",name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",val_key);
|
||||
i18nResourcesTextsJson.put("value",value);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
bodyJson.put("form",formArray);
|
||||
|
||||
// Iterator<Map.Entry<String, Object>> entries = textsMap.entrySet().iterator();
|
||||
// while (entries.hasNext()) {
|
||||
// Map.Entry<String, Object> entry = entries.next();
|
||||
// String key = entry.getKey();
|
||||
// String value = String.valueOf(entry.getValue());
|
||||
// JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
// i18nResourcesTextsJson.put("key",key);
|
||||
// i18nResourcesTextsJson.put("value",value);
|
||||
// i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
// }
|
||||
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsArray);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
return bodyJson.toJSONString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Esb2FeishuSendDoneUtil esb2FeishuSendTodoUtil = new Esb2FeishuSendDoneUtil();
|
||||
|
||||
String requestid = "1154744413522714631";
|
||||
String requestName = "督导奖励申请流程-石磊-2025-07-09";
|
||||
|
||||
String create_open_id = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String start_time = String.valueOf(System.currentTimeMillis());
|
||||
String end_time = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
Map<String, Object> textsMap = new HashMap<String,Object>();
|
||||
|
||||
List<Map<String, Object>> taskList = new ArrayList<Map<String, Object>>();
|
||||
Map<String,Object> taskMap = new HashMap<String,Object>();
|
||||
taskMap.put("open_id",create_open_id);
|
||||
taskList.add(taskMap);
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value","石磊");
|
||||
formList.add(formMap);
|
||||
formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value","紧急");
|
||||
formList.add(formMap);
|
||||
String node_id = "1151724772346716177";
|
||||
String nodeName = "1级审批";
|
||||
|
||||
// String data = esb2FeishuSendTodoUtil.appendBodyParam(requestid,
|
||||
// requestName,create_open_id,department_id,department_name,start_time,end_time,
|
||||
// formList,node_id,nodeName,new ArrayList<String>(),"","","");
|
||||
// System.out.println(data);
|
||||
|
||||
String date = "2025-07-17 21:07:48";
|
||||
|
||||
esb2FeishuSendTodoUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
|
||||
public long convertTimeStamp(String date) {
|
||||
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
if(date.contains("T")){
|
||||
date = date.replace("T"," ");
|
||||
}
|
||||
}
|
||||
System.out.println("date:"+date);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println("date:"+date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime();
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
log.error("timestamp:{}",timestamp);
|
||||
System.out.println(timestamp);
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,395 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
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 okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuSendFinishUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendFinishUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private WorkflowDegreeLevelDao workflowDegreeLevelDao;
|
||||
|
||||
public String 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,List<String> todoOpenIdList,
|
||||
String recepttime,String status
|
||||
) {
|
||||
log.error("senTodoMessage start");
|
||||
String code = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String createTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
createTimeStamp = String.valueOf(convertTimeStamp(createTime));
|
||||
}
|
||||
|
||||
String archivingTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(archivingTime)){
|
||||
archivingTimeStamp = String.valueOf(convertTimeStamp(archivingTime));
|
||||
}
|
||||
String receptTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
receptTimeStamp = String.valueOf(convertTimeStamp(recepttime));
|
||||
}
|
||||
|
||||
log.error("createTimeStamp:{}",createTimeStamp);
|
||||
log.error("archivingTimeStamp:{}",archivingTimeStamp);
|
||||
log.error("receptTimeStamp:{}",receptTimeStamp);
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
if(StringUtils.isNotBlank(creatorName)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value",creatorName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(degree)){
|
||||
Map<String,Object> degreeMap = workflowDegreeLevelDao.queryDegreeLevel();
|
||||
if(degreeMap.containsKey(degree)){
|
||||
String degreeName = String.valueOf(degreeMap.get(degree));
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value",degreeName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(requestmark)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","流程编号");
|
||||
formMap.put("value",requestmark);
|
||||
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","接收时间");
|
||||
formMap.put("value",recepttime);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
String bodyData = appendBodyParam(requestid,requestName,create_open_id,
|
||||
department_id,department_name,
|
||||
createTimeStamp,archivingTimeStamp,
|
||||
formList,nodeId,nodeName,todoOpenIdList,
|
||||
mobileurl, pcurl,receptTimeStamp,status);
|
||||
|
||||
log.error("feishu-finish:{}",bodyData);
|
||||
|
||||
String message = doPostSendMessage(bodyData,token);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
code = returnData.getString("code");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
public String doPostSendMessage(String bodyData,
|
||||
String token){
|
||||
String msg = "";
|
||||
|
||||
// "{\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()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.workflowApproveUrl)
|
||||
.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 appendBodyParam(String requestid,
|
||||
String requestName,
|
||||
String create_open_id,
|
||||
String department_id,
|
||||
String department_name,
|
||||
String createTimeStamp,
|
||||
String archivingTimeStamp,
|
||||
List<Map<String, Object>> formList,
|
||||
String node_id,
|
||||
String nodeName,
|
||||
List<String> todoOpenIdList,
|
||||
String mobileurl,
|
||||
String pcurl,
|
||||
String receptTimeStamp,
|
||||
String status
|
||||
){
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("approval_code",Constants.approvalCode);
|
||||
bodyJson.put("status",status);
|
||||
// JSONObject extraJson = new JSONObject();
|
||||
// extraJson.put("测试","测试");
|
||||
// bodyJson.put("extra",extraJson.toJSONString());
|
||||
bodyJson.put("instance_id",requestid);
|
||||
JSONObject linksJson = new JSONObject();
|
||||
linksJson.put("pc_link",Constants.HrmHost+pcurl);
|
||||
linksJson.put("mobile_link",Constants.HrmHost+mobileurl);
|
||||
bodyJson.put("links",linksJson);
|
||||
bodyJson.put("title","@i18n@title");
|
||||
|
||||
|
||||
// bodyJson.put("user_id",Constants.SysUserId);
|
||||
// bodyJson.put("user_name","@i18n@9");
|
||||
bodyJson.put("open_id",create_open_id);
|
||||
// bodyJson.put("department_id",department_id);
|
||||
|
||||
bodyJson.put("start_time",createTimeStamp);
|
||||
bodyJson.put("end_time",archivingTimeStamp);
|
||||
bodyJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
bodyJson.put("display_method",Constants.browser);
|
||||
bodyJson.put("update_mode",Constants.updateMode);
|
||||
|
||||
log.error("update_time:{}",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
JSONArray taskListArray = new JSONArray();
|
||||
for(int i=0;i<todoOpenIdList.size();i++){
|
||||
String task_open_id = String.valueOf(todoOpenIdList.get(i));
|
||||
log.error("task_open_id:"+task_open_id);
|
||||
JSONObject taskListJson = new JSONObject();
|
||||
taskListJson.put("task_id","weaver_"+requestid+"_"+task_open_id);
|
||||
taskListJson.put("open_id",task_open_id);
|
||||
taskListJson.put("title","@i18n@title");
|
||||
taskListJson.put("links",linksJson);
|
||||
taskListJson.put("status",status);
|
||||
taskListJson.put("create_time",receptTimeStamp);
|
||||
|
||||
taskListJson.put("end_time",archivingTimeStamp);
|
||||
taskListJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
taskListJson.put("display_method",Constants.browser);
|
||||
taskListJson.put("exclude_statistics",Constants.excludeStatistics);
|
||||
|
||||
// JSONArray actionConfigsArray = new JSONArray();
|
||||
// JSONObject actionConfigsJson = new JSONObject();
|
||||
// actionConfigsJson.put("action_type","APPROVE");
|
||||
// actionConfigsJson.put("action_name","@i18n@5");
|
||||
// actionConfigsJson.put("is_need_reason",false);
|
||||
// actionConfigsJson.put("is_need_approve_reason",false);
|
||||
// actionConfigsJson.put("is_need_comment",false);
|
||||
// actionConfigsArray.add(actionConfigsJson);
|
||||
// taskListJson.put("action_configs",actionConfigsArray);
|
||||
|
||||
taskListJson.put("node_id",node_id);
|
||||
taskListJson.put("node_name","@i18n@node");
|
||||
taskListArray.add(taskListJson);
|
||||
}
|
||||
|
||||
bodyJson.put("task_list",taskListArray);
|
||||
|
||||
|
||||
JSONArray i18nResourcesTextsArray = new JSONArray();
|
||||
|
||||
JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@title");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@node");
|
||||
i18nResourcesTextsJson.put("value",nodeName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
if(StringUtils.isNotBlank(department_id)){
|
||||
bodyJson.put("department_id",department_id);
|
||||
}else if(StringUtils.isNotBlank(department_name)){
|
||||
String key = "@i18n@departmentname";
|
||||
bodyJson.put("department_name",key);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key);
|
||||
i18nResourcesTextsJson.put("value",department_name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
|
||||
JSONArray formArray = new JSONArray();
|
||||
for(int i=0;i<formList.size();i++){
|
||||
Map<String,Object> formMap = formList.get(i);
|
||||
String name = formMap.get("name").toString();
|
||||
String value = formMap.get("value").toString();
|
||||
|
||||
String key_key = "@i18n@k"+i;
|
||||
String val_key = "@i18n@v"+i;
|
||||
|
||||
JSONObject formJson = new JSONObject();
|
||||
formJson.put("name",key_key);
|
||||
formJson.put("value",val_key);
|
||||
formArray.add(formJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key_key);
|
||||
i18nResourcesTextsJson.put("value",name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",val_key);
|
||||
i18nResourcesTextsJson.put("value",value);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
bodyJson.put("form",formArray);
|
||||
|
||||
// Iterator<Map.Entry<String, Object>> entries = textsMap.entrySet().iterator();
|
||||
// while (entries.hasNext()) {
|
||||
// Map.Entry<String, Object> entry = entries.next();
|
||||
// String key = entry.getKey();
|
||||
// String value = String.valueOf(entry.getValue());
|
||||
// JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
// i18nResourcesTextsJson.put("key",key);
|
||||
// i18nResourcesTextsJson.put("value",value);
|
||||
// i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
// }
|
||||
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsArray);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
return bodyJson.toJSONString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Esb2FeishuSendFinishUtil esb2FeishuSendTodoUtil = new Esb2FeishuSendFinishUtil();
|
||||
|
||||
String requestid = "1154744413522714631";
|
||||
String requestName = "督导奖励申请流程-石磊-2025-07-09";
|
||||
|
||||
String create_open_id = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String start_time = String.valueOf(System.currentTimeMillis());
|
||||
String end_time = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
Map<String, Object> textsMap = new HashMap<String,Object>();
|
||||
|
||||
List<Map<String, Object>> taskList = new ArrayList<Map<String, Object>>();
|
||||
Map<String,Object> taskMap = new HashMap<String,Object>();
|
||||
taskMap.put("open_id",create_open_id);
|
||||
taskList.add(taskMap);
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value","石磊");
|
||||
formList.add(formMap);
|
||||
formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value","紧急");
|
||||
formList.add(formMap);
|
||||
String node_id = "1151724772346716177";
|
||||
String nodeName = "1级审批";
|
||||
|
||||
// String data = esb2FeishuSendTodoUtil.appendBodyParam(requestid,
|
||||
// requestName,create_open_id,department_id,department_name,start_time,end_time,
|
||||
// formList,node_id,nodeName,new ArrayList<String>(),"","","");
|
||||
// System.out.println(data);
|
||||
|
||||
String date = "2025-07-17 21:07:48";
|
||||
|
||||
esb2FeishuSendTodoUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
|
||||
public long convertTimeStamp(String date) {
|
||||
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
if(date.contains("T")){
|
||||
date = date.replace("T"," ");
|
||||
}
|
||||
}
|
||||
System.out.println("date:"+date);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println("date:"+date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime();
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
log.error("timestamp:{}",timestamp);
|
||||
System.out.println(timestamp);
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,282 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuSendMessageUtil{
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendMessageUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
|
||||
public Map<String, Object> senCardMessage(String template_id,String template_version_name,String receiveId) {
|
||||
log.error("senCardMessage start");
|
||||
Map<String, Object> messageMap = new HashMap<String, Object>();
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
|
||||
JSONObject templateVariable = new JSONObject();
|
||||
templateVariable.put("name,","石磊");
|
||||
templateVariable.put("current_date,",sdf.format(new Date()));
|
||||
|
||||
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_variable",templateVariable.toJSONString());
|
||||
System.out.println("data_Json:"+data_Json.toJSONString());
|
||||
|
||||
JSONObject contentJson = new JSONObject();
|
||||
contentJson.put("type","template");
|
||||
contentJson.put("data",data_Json);
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("receive_id",receiveId);
|
||||
bodyJson.put("msg_type","interactive");
|
||||
bodyJson.put("content", contentJson.toJSONString());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
bodyJson.put("uuid", uuid);
|
||||
|
||||
System.out.println("bodyJson:"+bodyJson.toJSONString());
|
||||
|
||||
String message= doPostSendMessage(bodyJson.toJSONString(),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");
|
||||
String chat_id = dataJson.getString("chat_id");
|
||||
String msg_type = dataJson.getString("msg_type");
|
||||
String message_id = dataJson.getString("message_id");
|
||||
String create_time = dataJson.getString("create_time");
|
||||
|
||||
messageMap.put("chat_id",chat_id);
|
||||
messageMap.put("msg_type",msg_type);
|
||||
messageMap.put("message_id",message_id);
|
||||
messageMap.put("create_time",create_time);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return messageMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Map<String, Object> senTextMessage(String content,String receiveId) {
|
||||
log.error("senCardMessage start");
|
||||
Map<String, Object> messageMap = new HashMap<String, Object>();
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
JSONObject contentJson = new JSONObject();
|
||||
contentJson.put("text",content);
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("receive_id",receiveId);
|
||||
bodyJson.put("msg_type","text");
|
||||
bodyJson.put("content", contentJson.toJSONString());
|
||||
bodyJson.put("uuid", uuid);
|
||||
|
||||
System.out.println("bodyJson:"+bodyJson.toJSONString());
|
||||
|
||||
String message= doPostSendMessage(bodyJson.toJSONString(),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");
|
||||
String chat_id = dataJson.getString("chat_id");
|
||||
String msg_type = dataJson.getString("msg_type");
|
||||
String message_id = dataJson.getString("message_id");
|
||||
String create_time = dataJson.getString("create_time");
|
||||
|
||||
messageMap.put("chat_id",chat_id);
|
||||
messageMap.put("msg_type",msg_type);
|
||||
messageMap.put("message_id",message_id);
|
||||
messageMap.put("create_time",create_time);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return messageMap;
|
||||
}
|
||||
|
||||
|
||||
public String doPostSendMessage(String bodyData,String token){
|
||||
String msg = "";
|
||||
|
||||
// https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id
|
||||
// t-g1046ofDRKNCIEO3YKB42MQCDBZCYZGWAROROPGJ
|
||||
|
||||
// bodyData = "{\n \"receive_id\": \"ou_f2ee4ea6545e537c426fa058c31bab88\",\n \"msg_type\": \"interactive\",\n \"content\": \"{\\\"type\\\":\\\"template\\\",\\\"data\\\":{\\\"template_id\\\":\\\"AAqIMF4quXR02\\\",\\\"template_version_name\\\":\\\"1.0.1\\\",\\\"template_variable\\\":{\\\"name\\\":\\\"王文猛\\\",\\\"current_date\\\":\\\"06-24\\\"}}}\"\n}" ;
|
||||
|
||||
log.error("bodyData:{}",bodyData);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.messageUrl)
|
||||
.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;
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 获取token
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public String getToken() {
|
||||
// String token = (String) baseCache.get(FeishuTokenModuleKey.FENSHUTOKEN_DATACENTER, FeishuTokenCacheKey.FEISHU_TOKEN);
|
||||
// log.error("token:{}",token);
|
||||
// if (StringUtils.isBlank(token)) {
|
||||
// JSONObject returnData = getAccessToken();
|
||||
// if(returnData.containsKey("tenantAccessToken")){
|
||||
// token = returnData.getString("tenantAccessToken");
|
||||
// int expire = returnData.getInteger("expire");
|
||||
//
|
||||
// log.error("token:{}",token);
|
||||
// log.error("expire:{}",expire);
|
||||
//
|
||||
// if(expire > 0){
|
||||
// baseCache.set(FeishuTokenModuleKey.FENSHUTOKEN_DATACENTER, FeishuTokenCacheKey.FEISHU_TOKEN, token, expire);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return token;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public String getToken2() {
|
||||
// String token = "";
|
||||
// JSONObject returnData = getAccessToken();
|
||||
// if(returnData.containsKey("tenantAccessToken")){
|
||||
// token = returnData.getString("tenantAccessToken");
|
||||
// }
|
||||
// System.out.println("token:"+token);
|
||||
// return token;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public JSONObject getAccessToken() {
|
||||
//
|
||||
// // https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal
|
||||
// JSONObject returnData = new JSONObject();
|
||||
// JSONObject dataJson = new JSONObject();
|
||||
// dataJson.put("app_id", Constants.app_id);
|
||||
// dataJson.put("app_secret", Constants.app_secret);
|
||||
//
|
||||
// log.error("dataJson:{}",dataJson.toJSONString());
|
||||
//// dataJson.put("app_id", "cli_a8d0ee6b667dd00e");
|
||||
//// dataJson.put("app_secret", "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0");
|
||||
//
|
||||
// try {
|
||||
// OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
// .build();
|
||||
// MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
// RequestBody body = RequestBody.create(mediaType, dataJson.toJSONString());
|
||||
// Request request = new Request.Builder()
|
||||
// .url(Constants.feishuHost+Constants.tokenUrl)
|
||||
// .method("POST", body)
|
||||
// .addHeader("Content-Type", "application/json; charset=utf-8")
|
||||
// .build();
|
||||
// Response response = client.newCall(request).execute();
|
||||
// int code = response.code();
|
||||
// String msg = response.body().string();
|
||||
//
|
||||
// log.error("code:{}",code);
|
||||
// log.error("msg:{}",msg);
|
||||
//
|
||||
// if(code == 200){
|
||||
// if(StringUtils.isNotBlank(msg)){
|
||||
// JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
// if(returnJson.containsKey("code")){
|
||||
// String dataCode = returnJson.getString("code");
|
||||
// if("0".equals(dataCode)){
|
||||
// String tenantAccessToken = returnJson.getString("tenant_access_token");
|
||||
// int expire = returnJson.getInteger("expire");
|
||||
//
|
||||
// log.error("tenantAccessToken:{}",tenantAccessToken);
|
||||
// log.error("expire:{}",expire);
|
||||
//
|
||||
// returnData.put("tenantAccessToken",tenantAccessToken);
|
||||
// returnData.put("expire",expire - earlySecond);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// log.error("msg:{}",msg);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("msg:{}",e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return returnData;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @param bodyData
|
||||
// * @param token
|
||||
// * @return
|
||||
// */
|
||||
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// String feishuHost = "https://open.feishu.cn";
|
||||
// String tokenUrl = "/open-apis/auth/v3/tenant_access_token/internal";
|
||||
// String feishuUrl = "/open-apis/im/v1/messages?receive_id_type=open_id";
|
||||
// String app_id = "cli_a8d0ee6b667dd00e";
|
||||
// String app_secret = "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0";
|
||||
// String template_id = "AAqIMF4quXR02" ;
|
||||
// String template_version_name = "1.0.1";
|
||||
// String receiveId = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
//
|
||||
// Esb2FeishuSendMessageUtil esb2FeishuSendMessageUtil = new Esb2FeishuSendMessageUtil();
|
||||
// esb2FeishuSendMessageUtil.senCardMessage(template_id, template_version_name,receiveId);
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,390 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
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 okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuSendTodoUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuSendTodoUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private WorkflowDegreeLevelDao workflowDegreeLevelDao;
|
||||
|
||||
public String 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,List<String> todoOpenIdList,
|
||||
String recepttime,String status
|
||||
) {
|
||||
log.error("senTodoMessage start");
|
||||
String code = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String createTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(createTime)){
|
||||
createTimeStamp = String.valueOf(convertTimeStamp(createTime));
|
||||
}
|
||||
|
||||
String archivingTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(archivingTime)){
|
||||
archivingTimeStamp = String.valueOf(convertTimeStamp(archivingTime));
|
||||
}
|
||||
String receptTimeStamp = "0";
|
||||
if(StringUtils.isNotBlank(recepttime)){
|
||||
receptTimeStamp = String.valueOf(convertTimeStamp(recepttime));
|
||||
}
|
||||
|
||||
log.error("createTimeStamp:{}",createTimeStamp);
|
||||
log.error("archivingTimeStamp:{}",archivingTimeStamp);
|
||||
log.error("receptTimeStamp:{}",receptTimeStamp);
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
|
||||
if(StringUtils.isNotBlank(degree)){
|
||||
Map<String,Object> degreeMap = workflowDegreeLevelDao.queryDegreeLevel();
|
||||
if(degreeMap.containsKey(degree)){
|
||||
String degreeName = String.valueOf(degreeMap.get(degree));
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value",degreeName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(requestmark)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","流程编号");
|
||||
formMap.put("value",requestmark);
|
||||
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","接收时间");
|
||||
formMap.put("value",recepttime);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(creatorName)){
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value",creatorName);
|
||||
formList.add(formMap);
|
||||
}
|
||||
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
String bodyData = appendBodyParam(requestid,requestName,create_open_id,
|
||||
department_id,department_name,
|
||||
createTimeStamp,archivingTimeStamp,
|
||||
formList,nodeId,nodeName,todoOpenIdList,
|
||||
mobileurl, pcurl,receptTimeStamp,status);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
public String doPostSendMessage(String bodyData,
|
||||
String token){
|
||||
String msg = "";
|
||||
|
||||
// "{\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()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.workflowApproveUrl)
|
||||
.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 appendBodyParam(String requestid,
|
||||
String requestName,
|
||||
String create_open_id,
|
||||
String department_id,
|
||||
String department_name,
|
||||
String createTimeStamp,
|
||||
String archivingTimeStamp,
|
||||
List<Map<String, Object>> formList,
|
||||
String node_id,
|
||||
String nodeName,
|
||||
List<String> todoOpenIdList,
|
||||
String mobileurl,
|
||||
String pcurl,
|
||||
String receptTimeStamp,
|
||||
String status
|
||||
){
|
||||
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("approval_code",Constants.approvalCode);
|
||||
bodyJson.put("status",status);
|
||||
// JSONObject extraJson = new JSONObject();
|
||||
// extraJson.put("测试","测试");
|
||||
// bodyJson.put("extra",extraJson.toJSONString());
|
||||
bodyJson.put("instance_id",requestid);
|
||||
JSONObject linksJson = new JSONObject();
|
||||
linksJson.put("pc_link",Constants.HrmHost+pcurl);
|
||||
linksJson.put("mobile_link",Constants.HrmHost+mobileurl);
|
||||
bodyJson.put("links",linksJson);
|
||||
bodyJson.put("title","@i18n@title");
|
||||
|
||||
|
||||
// bodyJson.put("user_id",Constants.SysUserId);
|
||||
// bodyJson.put("user_name","@i18n@9");
|
||||
bodyJson.put("open_id",create_open_id);
|
||||
// bodyJson.put("department_id",department_id);
|
||||
|
||||
bodyJson.put("start_time",createTimeStamp);
|
||||
bodyJson.put("end_time",archivingTimeStamp);
|
||||
bodyJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
bodyJson.put("display_method",Constants.browser);
|
||||
bodyJson.put("update_mode",Constants.updateMode);
|
||||
|
||||
log.error("update_time:{}",String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
JSONArray taskListArray = new JSONArray();
|
||||
for(int i=0;i<todoOpenIdList.size();i++){
|
||||
String task_open_id = String.valueOf(todoOpenIdList.get(i));
|
||||
log.error("task_open_id:"+task_open_id);
|
||||
JSONObject taskListJson = new JSONObject();
|
||||
taskListJson.put("task_id","weaver_"+requestid+"_"+task_open_id);
|
||||
taskListJson.put("open_id",task_open_id);
|
||||
taskListJson.put("title","@i18n@title");
|
||||
taskListJson.put("links",linksJson);
|
||||
taskListJson.put("status",status);
|
||||
taskListJson.put("create_time",receptTimeStamp);
|
||||
|
||||
taskListJson.put("end_time",archivingTimeStamp);
|
||||
taskListJson.put("update_time",String.valueOf(System.currentTimeMillis()));
|
||||
taskListJson.put("display_method",Constants.browser);
|
||||
taskListJson.put("exclude_statistics",Constants.excludeStatistics);
|
||||
|
||||
// JSONArray actionConfigsArray = new JSONArray();
|
||||
// JSONObject actionConfigsJson = new JSONObject();
|
||||
// actionConfigsJson.put("action_type","APPROVE");
|
||||
// actionConfigsJson.put("action_name","@i18n@5");
|
||||
// actionConfigsJson.put("is_need_reason",false);
|
||||
// actionConfigsJson.put("is_need_approve_reason",false);
|
||||
// actionConfigsJson.put("is_need_comment",false);
|
||||
// actionConfigsArray.add(actionConfigsJson);
|
||||
// taskListJson.put("action_configs",actionConfigsArray);
|
||||
|
||||
taskListJson.put("node_id",node_id);
|
||||
taskListJson.put("node_name","@i18n@node");
|
||||
taskListArray.add(taskListJson);
|
||||
}
|
||||
|
||||
bodyJson.put("task_list",taskListArray);
|
||||
|
||||
|
||||
JSONArray i18nResourcesTextsArray = new JSONArray();
|
||||
|
||||
JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@title");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@node");
|
||||
i18nResourcesTextsJson.put("value",nodeName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
if(StringUtils.isNotBlank(department_id)){
|
||||
bodyJson.put("department_id",department_id);
|
||||
}else if(StringUtils.isNotBlank(department_name)){
|
||||
String key = "@i18n@departmentname";
|
||||
bodyJson.put("department_name",key);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key);
|
||||
i18nResourcesTextsJson.put("value",department_name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
|
||||
JSONArray formArray = new JSONArray();
|
||||
for(int i=0;i<formList.size();i++){
|
||||
Map<String,Object> formMap = formList.get(i);
|
||||
String name = formMap.get("name").toString();
|
||||
String value = formMap.get("value").toString();
|
||||
|
||||
String key_key = "@i18n@k"+i;
|
||||
String val_key = "@i18n@v"+i;
|
||||
|
||||
JSONObject formJson = new JSONObject();
|
||||
formJson.put("name",key_key);
|
||||
formJson.put("value",val_key);
|
||||
formArray.add(formJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",key_key);
|
||||
i18nResourcesTextsJson.put("value",name);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key",val_key);
|
||||
i18nResourcesTextsJson.put("value",value);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
}
|
||||
bodyJson.put("form",formArray);
|
||||
|
||||
// Iterator<Map.Entry<String, Object>> entries = textsMap.entrySet().iterator();
|
||||
// while (entries.hasNext()) {
|
||||
// Map.Entry<String, Object> entry = entries.next();
|
||||
// String key = entry.getKey();
|
||||
// String value = String.valueOf(entry.getValue());
|
||||
// JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
// i18nResourcesTextsJson.put("key",key);
|
||||
// i18nResourcesTextsJson.put("value",value);
|
||||
// i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
// }
|
||||
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsArray);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
return bodyJson.toJSONString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Esb2FeishuSendTodoUtil esb2FeishuSendTodoUtil = new Esb2FeishuSendTodoUtil();
|
||||
|
||||
String requestid = "1154744413522714631";
|
||||
String requestName = "督导奖励申请流程-石磊-2025-07-09";
|
||||
|
||||
String create_open_id = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String start_time = String.valueOf(System.currentTimeMillis());
|
||||
String end_time = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
Map<String, Object> textsMap = new HashMap<String,Object>();
|
||||
|
||||
List<Map<String, Object>> taskList = new ArrayList<Map<String, Object>>();
|
||||
Map<String,Object> taskMap = new HashMap<String,Object>();
|
||||
taskMap.put("open_id",create_open_id);
|
||||
taskList.add(taskMap);
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value","石磊");
|
||||
formList.add(formMap);
|
||||
formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value","紧急");
|
||||
formList.add(formMap);
|
||||
String node_id = "1151724772346716177";
|
||||
String nodeName = "1级审批";
|
||||
|
||||
// String data = esb2FeishuSendTodoUtil.appendBodyParam(requestid,
|
||||
// requestName,create_open_id,department_id,department_name,start_time,end_time,
|
||||
// formList,node_id,nodeName,new ArrayList<String>(),"","","");
|
||||
// System.out.println(data);
|
||||
|
||||
String date = "2025-07-17 21:07:48";
|
||||
|
||||
esb2FeishuSendTodoUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
|
||||
public long convertTimeStamp(String date) {
|
||||
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
if(date.contains("T")){
|
||||
date = date.replace("T"," ");
|
||||
}
|
||||
}
|
||||
System.out.println("date:"+date);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long timestamp = 0L;
|
||||
try{
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
System.out.println("date:"+date.length());
|
||||
if(date.length() == 10){
|
||||
date = date + " 00:00:00";
|
||||
}else if(date.length() == 16){
|
||||
date = date + ":00";
|
||||
}
|
||||
if(date.length() == 19){
|
||||
try {
|
||||
timestamp = sdf.parse(date).getTime();
|
||||
} catch (ParseException e) {
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
}
|
||||
log.error("timestamp:{}",timestamp);
|
||||
System.out.println(timestamp);
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("e:{}",e);
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.cache.base.BaseCache;
|
||||
import com.weaver.seconddev.chapanda.feishu.cache.FeishuTokenCacheKey;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.feishu.module.FeishuTokenModuleKey;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuTokenUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuTokenUtil.class);
|
||||
|
||||
@Autowired
|
||||
private BaseCache baseCache;
|
||||
|
||||
public int earlySecond = 120;
|
||||
|
||||
public String getToken() {
|
||||
String token = (String) baseCache.get(FeishuTokenModuleKey.FENSHUTOKEN_DATACENTER, FeishuTokenCacheKey.FEISHU_TOKEN);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
JSONObject returnData = getAccessToken();
|
||||
if(returnData.containsKey("tenantAccessToken")){
|
||||
token = returnData.getString("tenantAccessToken");
|
||||
int expire = returnData.getInteger("expire");
|
||||
if(expire > 0){
|
||||
baseCache.set(FeishuTokenModuleKey.FENSHUTOKEN_DATACENTER, FeishuTokenCacheKey.FEISHU_TOKEN, token, expire);
|
||||
}
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
public JSONObject getAccessToken() {
|
||||
|
||||
// https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal
|
||||
JSONObject returnData = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("app_id", Constants.app_id);
|
||||
dataJson.put("app_secret", Constants.app_secret);
|
||||
|
||||
// dataJson.put("app_id", "cli_a8d0ee6b667dd00e");
|
||||
// dataJson.put("app_secret", "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0");
|
||||
|
||||
try {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
RequestBody body = RequestBody.create(mediaType, dataJson.toJSONString());
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.tokenUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json; charset=utf-8")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("0".equals(dataCode)){
|
||||
String tenantAccessToken = returnJson.getString("tenant_access_token");
|
||||
int expire = returnJson.getInteger("expire");
|
||||
|
||||
returnData.put("tenantAccessToken",tenantAccessToken);
|
||||
returnData.put("expire",expire - earlySecond);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("e:{}",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuUploadImageUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuUploadImageUtil.class);
|
||||
|
||||
public String uploadImage() {
|
||||
log.error("esb2feishuuploadimageutil start");
|
||||
Map<String, Object> messageMap = new HashMap<String, Object>();
|
||||
String imageKey = "";
|
||||
String token = getToken2();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
|
||||
String fileName = "toux2.jpg";
|
||||
String filePath = "/Users/apple/Downloads/toux2.jpg";
|
||||
byte[] imageData = null;
|
||||
try {
|
||||
imageData = Files.readAllBytes(Paths.get(filePath));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String message= uploadImageByte(imageData,fileName,token);
|
||||
System.out.println(message);
|
||||
|
||||
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");
|
||||
imageKey = dataJson.getString("image_key");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imageKey;
|
||||
}
|
||||
|
||||
|
||||
public String getToken2() {
|
||||
String token = "";
|
||||
JSONObject returnData = getAccessToken();
|
||||
if(returnData.containsKey("tenantAccessToken")){
|
||||
token = returnData.getString("tenantAccessToken");
|
||||
}
|
||||
System.out.println("token:"+token);
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getAccessToken() {
|
||||
|
||||
JSONObject returnData = new JSONObject();
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("app_id", Constants.app_id);
|
||||
dataJson.put("app_secret", Constants.app_secret);
|
||||
|
||||
log.error("dataJson:{}",dataJson.toJSONString());
|
||||
// dataJson.put("app_id", "cli_a8d0ee6b667dd00e");
|
||||
// dataJson.put("app_secret", "UjShC4eY7vCgHsQvFWZZleVdCqSEWGD0");
|
||||
|
||||
try {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||
RequestBody body = RequestBody.create(mediaType, dataJson.toJSONString());
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.tokenUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json; charset=utf-8")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
int code = response.code();
|
||||
String msg = response.body().string();
|
||||
|
||||
log.error("code:{}",code);
|
||||
log.error("msg:{}",msg);
|
||||
|
||||
if(code == 200){
|
||||
if(StringUtils.isNotBlank(msg)){
|
||||
JSONObject returnJson = JSONObject.parseObject(msg);
|
||||
if(returnJson.containsKey("code")){
|
||||
String dataCode = returnJson.getString("code");
|
||||
if("0".equals(dataCode)){
|
||||
String tenantAccessToken = returnJson.getString("tenant_access_token");
|
||||
int expire = returnJson.getInteger("expire");
|
||||
|
||||
log.error("tenantAccessToken:{}",tenantAccessToken);
|
||||
log.error("expire:{}",expire);
|
||||
|
||||
returnData.put("tenantAccessToken",tenantAccessToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.error("msg:{}",msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("msg:{}",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public String uploadImageByte(byte[] imageData,String imageName,String token){
|
||||
String msg = "";
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
try {
|
||||
// "toux.jpg"
|
||||
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
|
||||
.addFormDataPart("image_type","avatar")
|
||||
.addFormDataPart("image",imageName,
|
||||
RequestBody.create(MediaType.parse("application/octet-stream"),
|
||||
imageData))
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.imageUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.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 static void main(String[] args) {
|
||||
|
||||
Esb2FeishuUploadImageUtil esb2FeishuSendMessageUtil = new Esb2FeishuUploadImageUtil();
|
||||
esb2FeishuSendMessageUtil.uploadImage();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.constant;
|
||||
|
||||
|
||||
public class Constants {
|
||||
public static String TENANT_KEY = "t024j0gfn0";
|
||||
|
||||
public static String HrmHost = "https://hrtest.chabaidao.com";
|
||||
|
||||
public static String OPENVER = "v1";
|
||||
public static String OPENTRANSCODE = "IFWAE003";
|
||||
|
||||
public static String OPENMERCODE = "CITICIFOP9999999";
|
||||
|
||||
public static String OPENMERNAME = "京东天天利";
|
||||
|
||||
public static String OPENBUSITYPE = "999";
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.esb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.kaixinyi.constant.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service("Esb2KaixinyAction")
|
||||
public class Esb2KaixinyAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2KaixinyAction.class);
|
||||
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2DmpGetGmvCron start");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
JSONObject dataJson = new JSONObject();
|
||||
dataJson.put("OPENVER", Constants.OPENVER);
|
||||
dataJson.put("OPENTRANSCODE", Constants.OPENTRANSCODE);
|
||||
dataJson.put("OPENMERNAME", Constants.OPENMERNAME);
|
||||
dataJson.put("OPENBUSITYPE", Constants.OPENBUSITYPE);
|
||||
dataJson.put("OPENLAUNCHDATE", sdf.format(new Date()));
|
||||
dataJson.put("OPENLAUNCHTIME", sdf1.format(new Date()));
|
||||
dataJson.put("OPENMERFLOWID", "IFOPH5SIMULATOR" + sdf2.format(new Date()));
|
||||
|
||||
dataJson.put("USER_ID", "1399999999");
|
||||
dataJson.put("CORP_ID", "1399999999");
|
||||
dataJson.put("PAY_NAME", "2025年06月薪酬发放");
|
||||
dataJson.put("PAY_FLAG", "1");
|
||||
dataJson.put("SETT_ACC", "1");
|
||||
dataJson.put("PAY_CNY", "001");
|
||||
dataJson.put("FLOW_ID", "001");
|
||||
|
||||
|
||||
JSONArray payDetail = new JSONArray();
|
||||
JSONObject payDetailJson = new JSONObject();
|
||||
payDetailJson.put("NUM","");
|
||||
payDetailJson.put("EMP_NAM","");
|
||||
payDetailJson.put("ID_TYP","");
|
||||
payDetailJson.put("ID_NO","");
|
||||
payDetailJson.put("CARD_NO","");
|
||||
payDetailJson.put("BANK_NO","");
|
||||
payDetailJson.put("PAY_AMT","");
|
||||
payDetailJson.put("CNY","");
|
||||
payDetailJson.put("CYFG","");
|
||||
payDetailJson.put("PAY_TYPE","");
|
||||
payDetailJson.put("TRN_ABS","");
|
||||
payDetailJson.put("TAX_ID","");
|
||||
payDetailJson.put("OTHER_BANK_MOB","");
|
||||
payDetail.add(payDetail);
|
||||
dataJson.put("LIST", payDetail);
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","Esb2DmpGetGmvCron");
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.util;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class AESUtil {
|
||||
|
||||
private static int KeySizeAES128 = 16;
|
||||
|
||||
private static Cipher getCipher(int mode, String key) {
|
||||
// mode =Cipher.DECRYPT_MODE or Cipher.ENCRYPT_MODE
|
||||
Cipher mCipher;
|
||||
byte[] keyPtr = new byte[KeySizeAES128];
|
||||
IvParameterSpec ivParam = new IvParameterSpec(keyPtr);
|
||||
byte[] passPtr = key.getBytes();
|
||||
try {
|
||||
mCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
for (int i = 0; i < KeySizeAES128; i++) {
|
||||
if (i < passPtr.length)
|
||||
keyPtr[i] = passPtr[i];
|
||||
else
|
||||
keyPtr[i] = 0;
|
||||
}
|
||||
SecretKeySpec keySpec = new SecretKeySpec(keyPtr, "AES");
|
||||
mCipher.init(mode, keySpec, ivParam);
|
||||
return mCipher;
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] encrypt(String content, String password) {
|
||||
try {
|
||||
Cipher cipher = getCipher(Cipher.ENCRYPT_MODE, password);// 创建密码器
|
||||
byte[] result = cipher.doFinal(content.getBytes("UTF-8"));// 加密
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] decrypt(byte[] content, String password) {
|
||||
try {
|
||||
Cipher cipher = getCipher(Cipher.DECRYPT_MODE, password);// 创建密码器
|
||||
byte[] result = cipher.doFinal(content);
|
||||
return result; // 明文
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getRandomAESKey() {
|
||||
int $aes_ken_len = 16;
|
||||
String aes_key_str = "";
|
||||
char[] e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
.toCharArray();
|
||||
int index = 0;
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < $aes_ken_len; i++) {
|
||||
index = r.nextInt(64);
|
||||
aes_key_str += e[index];
|
||||
}
|
||||
return aes_key_str;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.util;
|
||||
|
||||
public class DecryptUtil {
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.util;
|
||||
|
||||
//import com.lsy.baselib.crypto.util.Base64;
|
||||
//import com.lsy.baselib.crypto.util.CryptUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
//import javax.crypto.Cipher;
|
||||
//import java.io.ByteArrayOutputStream;
|
||||
//import java.security.Key;
|
||||
//import java.security.PublicKey;
|
||||
//import java.security.cert.X509Certificate;
|
||||
//import java.security.interfaces.RSAKey;
|
||||
|
||||
|
||||
@Component
|
||||
public class EncryptionUtil {
|
||||
|
||||
// private String encryptBusiness(String business) throws Exception {
|
||||
// String encryptKey = AESUtil.getRandomAESKey();
|
||||
// byte[] encryptBusinessDataByte = AESUtil.encrypt(business, encryptKey);
|
||||
//
|
||||
// String encryptBusiness = new String(
|
||||
// Base64.encode(encryptBusinessDataByte), "UTF-8");
|
||||
//
|
||||
// String publicKey = "MIIDQTCCAimgAwIBAgIBMDANBgkqhkiG9w0BAQUFADA6MQswCQYDVQQGEwJDTjENMAsGA1UECwwEQ05DQjEcMBoGA1UEAwwTYjJjLmJhbmsuZWNpdGljLmNvbTAgFw0xODEwMjIwMjU0MjZaGA8yMTE4MDkyODAyNTQyNlowOjELMAkGA1UEBhMCQ04xDTALBgNVBAsMBENOQ0IxHDAaBgNVBAMME2IyYy5iYW5rLmVjaXRpYy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCJe5k8J5oxkRbfrNHHbN8MEce9lkV/HWrKtpEtknRICpyT24Rx3xiCkyFfC2Zn0sYofJAcAvKElDupIIuYJHMvwWgakYHVHAbsp8XfGDToDeZdabCPSaV/tC+pbcZjnF+Zdlmy/TL9Yzxe/lSqhAnjk2wIeBQUy27CpcOKO7GXMVFE9TgogqDND+hYYzyaj+8gh73DRu2xSAq+ZTvJuW+bPvuALEOK/Ex8MO9u0oV1nn3OwkPkE/98jSs8BWBRDDGuh9OaZrUoNsF7II/e10Ad93lPf7UTEAiosO7ZiyJ+MBGy+cbkCwjpe5OOrkFr+9GNI6pjcDYul2KgI6XXdX0bAgMBAAGjUDBOMB0GA1UdDgQWBBTFTb+SBCIKxAdjuaOlferd/wKWYTAfBgNVHSMEGDAWgBTFTb+SBCIKxAdjuaOlferd/wKWYTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQA4zYjdRonussCKJGAK+KKI1Ov8ptG9lxuUEjDFCYGG0hgyDfUxuNAIWI3GaDIxfreR/YMXPEOzEl4yORzFEu/ekh5gQvNT674x29BaA1iOKW1w5OJ7N1msJ76J66V4o1FQuFxZFO3U5nIx10eMe1VUezBIRrVO0YXMnCwA4Ckc9m1+5vEWhB78oLLSLgNhUcIwDyXyyb48TjeUO9TGCDECaadLLPsKSEiQ/fp5Nbo2VFrrx3IUMBJDxu6LiXAEZwQ8/cc8O//sT7t5ezu4joLNKGU8Sl6MSW5k2cee76g52MaA0Zt1x3G2viAMtkj5w1hJs8rsMA7+aty6tnbELWZe";
|
||||
// byte[] base64EncodedSenderCert = publicKey.getBytes("UTF-8");
|
||||
//
|
||||
// X509Certificate signerCertificate = CryptUtil
|
||||
// .generateX509Certificate(com.lsy.baselib.crypto.util.Base64
|
||||
// .decode(base64EncodedSenderCert));
|
||||
// PublicKey signpublicKey = signerCertificate.getPublicKey();
|
||||
//
|
||||
// byte[] encryptKeyByte = encrypt((RSAKey) signpublicKey,
|
||||
// encryptKey.getBytes("UTF-8"));
|
||||
// String encryptKeyString = new String(Base64.encode(encryptKeyByte),
|
||||
// "UTF-8");
|
||||
//
|
||||
// encryptBusiness = encryptBusiness + "@@" + encryptKeyString;
|
||||
//
|
||||
// return encryptBusiness;
|
||||
// }
|
||||
//
|
||||
// private byte[] encrypt(RSAKey key, byte[] data) {
|
||||
// try {
|
||||
// Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding", "BC");
|
||||
// cipher.init(1, (Key) key);
|
||||
// int step = key.getModulus().bitLength() / 8;
|
||||
// int n = data.length / step;
|
||||
// if (n > 0) {
|
||||
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
// for (int i = 0; i < n; i++) {
|
||||
// baos.write(cipher.doFinal(data, i * step, step));
|
||||
// }
|
||||
// if ((n = data.length % step) != 0) {
|
||||
// baos.write(cipher.doFinal(data, data.length - n, n));
|
||||
// }
|
||||
// return baos.toByteArray();
|
||||
// }
|
||||
// return cipher.doFinal(data);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
package com.weaver.seconddev.chapanda.kaixinyi.util;
|
||||
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.lsy.baselib.crypto.util.Base64;
|
||||
//import com.lsy.baselib.crypto.util.CryptUtil;
|
||||
//import com.lsy.baselib.crypto.util.FileUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
//import java.io.UnsupportedEncodingException;
|
||||
//import java.security.PrivateKey;
|
||||
//import java.security.Signature;
|
||||
//import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SignatureUtil {
|
||||
|
||||
// private String signData(String data,String redirectURL) {
|
||||
// try {
|
||||
// String reSbf = data;
|
||||
// if(redirectURL.indexOf("/pay")==-1){
|
||||
// data = data.replace("\r|\n", "");
|
||||
// JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
// //对报文中的key字段进行ASCII排序
|
||||
// StringBuffer sbf = formaturlMap(jsonObject);
|
||||
// reSbf = sbf.toString().replaceAll("\\}\\{", "\\},\\{");
|
||||
// }
|
||||
//
|
||||
// byte[] msg = reSbf.getBytes("UTF-8");
|
||||
//
|
||||
// //签名数据
|
||||
// PrivateKey privateKey = getPrivateKey();
|
||||
// Signature signature = Signature.getInstance("SHA1WithRSA");
|
||||
// signature.initSign(privateKey);
|
||||
// signature.update(msg);
|
||||
// byte[] bytarr = signature.sign();
|
||||
//
|
||||
// String signData = new String(Base64.encode(bytarr), "UTF-8");
|
||||
// signData = signData.replace("\r|\n", "");
|
||||
// return signData;
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private PrivateKey getPrivateKey() throws Exception {
|
||||
// //私钥文件路径
|
||||
// String keyfile = SignatureUtil.class.getClassLoader().getResource("signkey/server_sign.key")
|
||||
// .getPath();
|
||||
// byte[] base64EncodedPrivatekey = FileUtil.read4file(keyfile);
|
||||
//
|
||||
// //私钥密码文件路径
|
||||
// String pwdfile = SignatureUtil.class.getClassLoader().getResource("signkey/server_sign.pwd")
|
||||
// .getPath();
|
||||
// byte[] base64EncodedPrivatekeyPass = FileUtil.read4file(pwdfile);
|
||||
//
|
||||
// char[] keyPassword = new String(base64EncodedPrivatekeyPass, "UTF-8").toCharArray();
|
||||
//
|
||||
// PrivateKey signerPrivatekey = CryptUtil.decryptPrivateKey(
|
||||
// Base64.decode(base64EncodedPrivatekey), keyPassword);
|
||||
// return signerPrivatekey;
|
||||
// }
|
||||
//
|
||||
// private StringBuffer formaturlMap(JSONObject jsonObject)
|
||||
// throws UnsupportedEncodingException {
|
||||
//
|
||||
// if (jsonObject == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// StringBuffer plain = new StringBuffer();
|
||||
// List<Map.Entry<String, Object>> infolds = new ArrayList<Map.Entry<String, Object>>(
|
||||
// jsonObject.entrySet());
|
||||
//
|
||||
// //ASCII 排序(字典序)
|
||||
// Collections.sort(infolds, new Comparator<Map.Entry<String, Object>>() {
|
||||
// public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
|
||||
// return (o1.getKey().compareTo(o2.getKey()));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// plain.append("{");
|
||||
// for (Map.Entry<String, Object> item : infolds) {
|
||||
// String key = item.getKey();
|
||||
// if ("commonDataList".equalsIgnoreCase(key)) {
|
||||
// continue;
|
||||
// }
|
||||
// plain.append("\"" + key + "\"");
|
||||
// plain.append(":");
|
||||
// Object val = item.getValue();
|
||||
// if (val instanceof JSONObject) {
|
||||
// StringBuffer str = formaturlMap((JSONObject) val);
|
||||
// plain.append(str);
|
||||
// } else if (val instanceof String) {
|
||||
// plain.append("\"" + val + "\"");
|
||||
// } else if (val instanceof JSONArray) {
|
||||
// plain.append("[");
|
||||
// JSONArray arr = (JSONArray) val;
|
||||
// for (int i = 0; i < arr.size(); i++) {
|
||||
// StringBuffer tempstr = new StringBuffer();
|
||||
// Object obj = arr.get(i);
|
||||
// if (obj instanceof JSONObject) {
|
||||
// tempstr = formaturlMap((JSONObject) obj);
|
||||
// }
|
||||
// plain.append(tempstr);
|
||||
// }
|
||||
// plain.append("]");
|
||||
// }
|
||||
// plain.append(",");
|
||||
// }
|
||||
// plain.delete(plain.length() - 1, plain.length());
|
||||
// if (plain.length() > 0) {
|
||||
// plain.append("}");
|
||||
// }
|
||||
// return plain;
|
||||
// }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue