Commit a4e49e70 authored by hongguangwu's avatar hongguangwu

MVP1.6.9-企微招聘平台

parent c8ba7ef0
......@@ -67,4 +67,18 @@ public class EkpPermissionTask {
log.info("-------------获取HCM出差数据-定时任务结束------------");
}
/**
* @Author hgw
* @Description 每天1点30,定时同步企微招聘数据
* @Date 2024-8-28 11:39:32
* @Param
**/
public void everyDaySaveQiWeiZhaoPin() throws Exception {
log.info("-------------获取企微招聘数据-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprEkpPermissionProperties.getAppUrl(), daprEkpPermissionProperties.getAppId(),
"/qiWei/inner/everyDaySaveQiWeiZhaoPin", "", Object.class,
SecurityConstants.FROM_IN);
log.info("-------------获取企微招聘数据-定时任务结束------------");
}
}
\ No newline at end of file
package com.yifu.cloud.plus.v1.yifu.permission.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 企业微信出差
*/
@TableName(value = "ekp_qiwei_zhaopin")
@Data
@Schema(description = "企业微信招聘")
public class EkpQiwiZhaoPin {
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键", name = "fdId")
private String fdId;
@Schema(description = "审批编号")
@NotBlank(message = "审批编号不能为空")
private String fdSpNo;
@Schema(description = "申请人姓名")
@NotBlank(message = "申请人姓名不能为空")
private String fdApplyUserName;
@Schema(description = "申请人部门")
@NotBlank(message = "申请人部门不能为空")
private String fdApplyUserDept;
@Schema(description = "申请日期")
@NotNull(message = "申请日期不能为空")
private LocalDateTime fdApplyDate;
@Schema(description = "开始时间")
private LocalDate fdNewBegin;
@Schema(description = "结束时间")
private LocalDate fdNewEnd;
// status 0 初始;1已结算;
@Schema(description = "结算状态")
private String fdStatus;
@Schema(description = "关联结算ID")
private String fdSettleFormId;
@Schema(description = "创建时间")
private LocalDateTime createTime;
// 企微、HCM
@Schema(description = "数据源")
private String fdDataSource;
// 新字段
@Schema(description = "申请子 (分) 公司或部门名称")
@NotBlank(message = "申请子 (分) 公司或部门名称")
private String fdUserDeptName;
@Schema(description = "购买方式")
private String fdBuyStyle;
@Schema(description = "平台名称")
private String fdPingTaiName;
@Schema(description = "平台产品名称")
private String fdPingTaiChanPin;
@Schema(description = "数量")
private String fdNum;
@Schema(description = "单价")
private String fdMoney;
@Schema(description = "总计金额")
private String fdMoneySum;
@Schema(description = "使用项目名称")
private String fdDeptName;
@Schema(description = "使用岗位名称")
private String fdPostName;
@Schema(description = "成本归属")
private String fdCostName;
// 招聘运营部填写
@Schema(description = "购买/调配方式是否合理")
private String fdTwoIsHeLi;
@Schema(description = "平台名称")
private String fdTwoPingTaiName;
@Schema(description = "产品名称")
private String fdTwoPingTaiChanPin;
@Schema(description = "数量")
private String fdTwoNum;
@Schema(description = "金额")
private String fdTwoMoneySum;
@Schema(description = "被调配的业务单元名称")
private String fdTwoYeWu;
@Schema(description = "备注")
private String fdTwoRemark;
@Schema(description = "关联结算单号")
private String fdSettleFormNo;
}
\ No newline at end of file
package com.yifu.cloud.plus.v1.permission.controller;
import com.yifu.cloud.plus.v1.permission.service.QiWeiService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
......@@ -85,4 +88,49 @@ public class QiWeiController {
return wxSalaryService.getQiWeiChuChaiAndSave(startTime, endTime, 2);
}
/**
* @Description: 每日获取当日企业微信审批里的【招聘平台采购/调配】
* @Author: hgw
* @Date: 2024-8-22 11:16:58
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TEventFeeDetail>>
**/
@PostMapping("/inner/everyDaySaveQiWeiZhaoPin")
@Inner
public R<List<EkpQiwiZhaoPin>> everyDaySaveQiWeiZhaoPin() {
String startDay = DateUtil.addDay(-29);
String endDay = DateUtil.addDay(0);
return wxSalaryService.getQiWeiZhaoPinAndSave(startDay, endDay);
}
/**
* @Description: 手动同步企微信息--EKP调用接口
* @Author: hgw
* @Date: 2024-8-28 11:23:18
**/
@Operation(summary = "手动同步企微信息--EKP调用接口", description = "手动同步企微信息--EKP调用接口")
@SysLog("手动同步企微信息--EKP调用接口")
@GetMapping("/getQiWeiZhaoPinInfo")
public R<String> getQiWeiZhaoPinInfo() {
String startDay = DateUtil.addDay(-29);
String endDay = DateUtil.addDay(0);
R<List<EkpQiwiZhaoPin>> returnR = wxSalaryService.getQiWeiZhaoPinAndSave(startDay, endDay);
if (returnR != null && returnR.getCode() == CommonConstants.SUCCESS) {
return R.ok();
}
return R.failed();
}
/**
* @param startTime
* @param endTime
* @Description: 获取企业微信审批里的【招聘平台采购/调配】
* @Author: hgw
* @Date: 2024-8-22 11:16:58
**/
@Operation(description = "获取企业微信审批里的招聘平台采购数据:startTime格式:2024-04-10")
@PostMapping("/getQiWeiZhaoPinInfoAndSave")
public R<List<EkpQiwiZhaoPin>> getQiWeiZhaoPinInfoAndSave(@RequestParam String startTime, @RequestParam String endTime) {
return wxSalaryService.getQiWeiZhaoPinAndSave(startTime, endTime);
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.permission.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 企微招聘
*
* @author hgw
* @date 2024-08-26 17:44:50
*/
@Mapper
public interface EkpQiweiZhaopinMapper extends BaseMapper<EkpQiwiZhaoPin> {
/**
* @param status 状态
* @Description: 获取全部的列表,用来: 拉取企业微信时,不覆盖数据
* @Author: hgw
* @Date: 2024-8-26 17:52:26
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.salary.TStatisticsProjectReimburse>
**/
List<EkpQiwiZhaoPin> getZhaoPinAllInfo(@Param("status") String status);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.permission.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import java.util.Map;
/**
* 企微招聘
*
* @author hgw
* @date 2024-08-26 17:44:50
*/
public interface EkpQiweiZhaopinService extends IService<EkpQiwiZhaoPin> {
/**
* @Description: 获取全部的列表,用来: 拉取企业微信时,不覆盖数据
* @Author: hgw
* @Date: 2024/8/26 17:56
* @return: java.util.Map<java.lang.String, java.lang.String>
**/
Map<String, String> getZhaoPinAllMap();
}
......@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.permission.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import java.util.List;
......@@ -25,4 +26,13 @@ public interface QiWeiService extends IService<EkpQiwiChuchai> {
**/
R<List<EkpQiwiChuchai>> getQiWeiChuChaiAndSave(String startTime, String endTime, int type);
/**
* @Description: 获取企业微信审批里的【招聘平台采购/调配】
* @Author: hgw
* @Date: 2024/8/22 11:18
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai>>
**/
R<List<EkpQiwiZhaoPin>> getQiWeiZhaoPinAndSave(String startTime, String endTime);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.permission.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.permission.mapper.EkpQiweiZhaopinMapper;
import com.yifu.cloud.plus.v1.permission.service.EkpQiweiZhaopinService;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 企微招聘
*
* @author hgw
* @date 2024-08-26 17:44:50
*/
@Log4j2
@Service
public class EkpQiweiZhaopinServiceImpl extends ServiceImpl<EkpQiweiZhaopinMapper, EkpQiwiZhaoPin> implements EkpQiweiZhaopinService {
/**
* @Description: 获取全部的列表,用来: 拉取企业微信时,不覆盖数据
* @Author: hgw
* @Date: 2024-8-26 17:54:23
* @return: java.util.Map<java.lang.String, java.lang.String>
**/
@Override
public Map<String, String> getZhaoPinAllMap() {
List<EkpQiwiZhaoPin> cpHistoryList = baseMapper.getZhaoPinAllInfo(null);
Map<String, String> cpMap = new HashMap<>();
for (EkpQiwiZhaoPin cpHis : cpHistoryList) {
cpMap.put(cpHis.getFdSpNo(), "0");
}
return cpMap;
}
}
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.permission.config.WxConfig;
import com.yifu.cloud.plus.v1.permission.mapper.EkpQiweiChuchaiMapper;
import com.yifu.cloud.plus.v1.permission.service.EkpQiweiZhaopinService;
import com.yifu.cloud.plus.v1.permission.service.QiWeiService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
......@@ -14,6 +15,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.LocalDateTimeUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.insurances.util.LocalDateUtil;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin;
import com.yifu.cloud.plus.v1.yifu.permission.vo.QiWeiUserVo;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpEntity;
......@@ -43,12 +45,88 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
private static final String VALUESTR = "value";
private static final String NEW_NEXT_CURSOR = "new_next_cursor";
private static final String NEW_CURSOR = "new_cursor";
private static final String TIME_PATTEN = "yyyy-MM-dd HH:mm:ss";
private static final String START_TIME = " 00:00:00";
private static final String END_TIME = " 23:59:59";
private final WxConfig wxConfig;
private final EkpQiweiZhaopinService ekpQiwiZhaoPinService;
/**
* @Description: 获取企业微信审批里的【招聘平台采购/调配】
* @Author: hgw
* @Date: 2024-8-22 11:19:52
**/
@Override
public synchronized R<List<EkpQiwiZhaoPin>> getQiWeiZhaoPinAndSave(String startTime, String endTime) {
try {
// 起止时间
DateTimeFormatter df = DateTimeFormatter.ofPattern(TIME_PATTEN);
LocalDateTime startDate = LocalDateTime.parse(startTime + START_TIME, df);
LocalDateTime endDate = LocalDateTime.parse(endTime + END_TIME, df);
Duration duration = Duration.between(startDate, endDate);
long days = duration.toDays(); //相差的天数
// 判断时间跨度:
if (days > 30) {
return R.failed("时间范围超过30天了:起:" + startTime + ";止:" + endTime);
}
// 获取起月份的起止时间
SimpleDateFormat sdf = new SimpleDateFormat(TIME_PATTEN);
Date startTimeDate = sdf.parse(startTime + START_TIME);
Date endTimeDate = sdf.parse(endTime + END_TIME);
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(startTimeDate);
startTime = String.valueOf(rightNow.getTime().getTime() / 1000);
rightNow.setTime(endTimeDate);
endTime = String.valueOf(rightNow.getTime().getTime() / 1000);
// 已被拉取的Map
Map<String, String> cpMap = ekpQiwiZhaoPinService.getZhaoPinAllMap();
// 企微姓名Map
Map<String, String> userMap = this.getUserMap();
// 一个月的全量编码数据
List<EkpQiwiChuchai> cpAllList = new ArrayList<>();
List<EkpQiwiZhaoPin> returnCpList = new ArrayList<>();
String qwType = "zhaoPin";
this.getCostPaymentListByMonth(startTime, endTime, cpAllList, qwType);
log.debug("1拉取企业微信招聘数据cpAllList.size()=" + cpAllList.size());
if (!cpAllList.isEmpty()) {
EkpQiwiZhaoPin zhaoPin;
for (EkpQiwiChuchai cp : cpAllList) {
if (cpMap.get(cp.getFdSpNo()) == null) {
zhaoPin = new EkpQiwiZhaoPin();
zhaoPin.setFdSpNo(cp.getFdSpNo());
zhaoPin.setFdStatus(CommonConstants.ZERO_STRING);
returnCpList.add(zhaoPin);
}
}
}
log.debug("1拉取企业微信招聘数据returnCpList.size()=" + returnCpList.size());
// 填充详情
if (!returnCpList.isEmpty()) {
log.debug("拉取企业微信招聘数据:" + returnCpList.size() + " 条,开始循环拉取明细!");
this.getTStatisticsProjectReimburseDetailByZhaoPin(returnCpList, userMap);
log.debug("拉取企业微信招聘数据结束");
}
// 填充基础数据并保存:
if (!returnCpList.isEmpty()) {
ekpQiwiZhaoPinService.saveBatch(returnCpList);
}
cpMap.clear();
userMap.clear();
return new R<>(returnCpList);
} catch (Exception e) {
e.printStackTrace();
log.error("拉取企业微信招聘失败:", e);
return R.failed("时间转化失败,请选择合适的时间,例如:2021-07-29,且范围不超过30天。" + e.getMessage());
}
}
/**
* @param startTime
* @param endTime
* @param type 1:企业微信;2:HCM的E人事
* @param type 1:企业微信;2:HCM的E人事
* @Description: 获取所有的出差
* @Author: hgw
* @Date: 2021/3/24 15:41
......@@ -58,21 +136,21 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
public synchronized R<List<EkpQiwiChuchai>> getQiWeiChuChaiAndSave(String startTime, String endTime, int type) {
try {
// 起止时间
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime startDate = LocalDateTime.parse(startTime + " 00:00:00", df);
LocalDateTime endDate = LocalDateTime.parse(endTime + " 23:59:59", df);
DateTimeFormatter df = DateTimeFormatter.ofPattern(TIME_PATTEN);
LocalDateTime startDate = LocalDateTime.parse(startTime + START_TIME, df);
LocalDateTime endDate = LocalDateTime.parse(endTime + END_TIME, df);
Duration duration = Duration.between(startDate, endDate);
long days = duration.toDays(); //相差的天数
// 判断时间跨度:
if (days > 30) {
return R.failed("时间范围超过30天了:起:" + startTime + ";止:" + endTime);
}
String startTimes = startTime + " 00:00:00";
String endTimes = endTime + " 23:59:59";
String startTimes = startTime + START_TIME;
String endTimes = endTime + END_TIME;
// 获取起月份的起止时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTimeDate = sdf.parse(startTime + " 00:00:00");
Date endTimeDate = sdf.parse(endTime + " 23:59:59");
SimpleDateFormat sdf = new SimpleDateFormat(TIME_PATTEN);
Date startTimeDate = sdf.parse(startTime + START_TIME);
Date endTimeDate = sdf.parse(endTime + END_TIME);
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(startTimeDate);
startTime = String.valueOf(rightNow.getTime().getTime() / 1000);
......@@ -93,7 +171,8 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
cpMap = this.getAllMap();
// 企微姓名Map
userMap = this.getUserMap();
this.getCostPaymentListByMonth(startTime, endTime, cpAllList);
String qwType = "chuChai";
this.getCostPaymentListByMonth(startTime, endTime, cpAllList, qwType);
log.error("1拉取企业微信出差数据cpAllList.size()=" + cpAllList.size());
if (!cpAllList.isEmpty()) {
for (EkpQiwiChuchai cp : cpAllList) {
......@@ -105,7 +184,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
log.error("1拉取企业微信出差数据returnCpList.size()=" + returnCpList.size());
// 填充详情
if (!returnCpList.isEmpty()) {
log.error("拉取企业微信出差数据:"+returnCpList.size()+" 条,开始循环拉取明细!");
log.error("拉取企业微信出差数据:" + returnCpList.size() + " 条,开始循环拉取明细!");
this.getTStatisticsProjectReimburseDetail(returnCpList, userMap);
log.error("拉取企业微信出差数据结束");
}
......@@ -147,9 +226,9 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
* @Date: 2021/3/24 17:50
* @return: void
**/
private void getCostPaymentListByMonth(String startTime, String endTime, List<EkpQiwiChuchai> cpAllList) {
private void getCostPaymentListByMonth(String startTime, String endTime, List<EkpQiwiChuchai> cpAllList, String qwType) {
// 当月的全量数据
R<List<EkpQiwiChuchai>> listR = this.getTStatisticsProjectReimburseListByWx(startTime, endTime);
R<List<EkpQiwiChuchai>> listR = this.getTStatisticsProjectReimburseListByWx(startTime, endTime, qwType);
if (listR.getCode() == CommonConstants.SUCCESS) {
cpAllList.addAll(listR.getData());
}
......@@ -161,15 +240,24 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
* @Date: 2021/3/18 14:58
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>
**/
private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseListByWx(String startTime, String endTime) {
private R<List<EkpQiwiChuchai>> getTStatisticsProjectReimburseListByWx(String startTime, String endTime, String qwType) {
String accessToken = wxConfig.getReimbursementToken(restTemplate);
log.error("1拉取企业微信出差数据accessToken=" + accessToken);
JSONObject json = new JSONObject();
List<Map<String, String>> paramList = new ArrayList<>();
Map<String, String> paramMap = new HashMap<>();
// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
paramMap.put("key", "record_type");
paramMap.put("value", "3");
if (Common.isEmpty(qwType) || "chuChai".equals(qwType)) {
// record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
paramMap.put("key", "record_type");
paramMap.put("value", "3");
} else if ("zhaoPin".equals(qwType)) {
paramMap.put("key", "template_id");
// 模板id,从功能的编辑的url里找
// https://work.weixin.qq.com/wework_admin/frame#approval_v2/app/264/3WLuP5gXZf3UFAJJa3WSouuP56UFJsQGgCWdo3zs
paramMap.put("value", "3WLuP5gXZf3UFAJJa3WSouuP56UFJsQGgCWdo3zs");
}
paramList.add(paramMap);
paramMap = new HashMap<>();
// sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付
......@@ -273,13 +361,13 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
int renShu2;
String tools;
String dataSource = "HCM";
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter df = DateTimeFormatter.ofPattern(TIME_PATTEN);
List<JSONObject> toolList;
Map<String, String> toolMap = new HashMap<>();
toolMap.put("1","飞机");
toolMap.put("2","自驾");
toolMap.put("3","汽车");
toolMap.put("4","高铁火车");
toolMap.put("1", "飞机");
toolMap.put("2", "自驾");
toolMap.put("3", "汽车");
toolMap.put("4", "高铁火车");
for (JSONObject datas : dataList) {
person = null;
renShu = 1;
......@@ -326,9 +414,9 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
renShu1 = person.split(",").length;
renShu2 = person.split(",").length;
if (renShu1 > renShu2) {
renShu +=renShu1;
renShu += renShu1;
} else {
renShu +=renShu2;
renShu += renShu2;
}
}
}
......@@ -358,7 +446,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
}
}
}
} catch (Exception e ) {
} catch (Exception e) {
person = "-";
renShu = 1;
tools = null;
......@@ -378,6 +466,56 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
return R.ok();
}
/**
* @Description: 从企业微信-获取详情
* @Author: hgw
* @Date: 2024-4-12 16:55:00
* @return: java.util.List<com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>
**/
private R<List<EkpQiwiZhaoPin>> getTStatisticsProjectReimburseDetailByZhaoPin(List<EkpQiwiZhaoPin> list, Map<String, String> userMap) {
String accessToken = wxConfig.getReimbursementToken(restTemplate);
int i = 1;
JSONObject jsonDetail;
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> formEntityDetail;
String dataResultDetail;
JSONObject jsonObject;
String errcode;
String errmsg;
String info;
for (EkpQiwiZhaoPin r : list) {
log.error("企业微信招聘【" + i + "/" + "" + list.size() + "】条");
jsonDetail = new JSONObject();
jsonDetail.put("sp_no", r.getFdSpNo());
formEntityDetail = new HttpEntity<>(jsonDetail.toString(), headers);
dataResultDetail = restTemplate.postForEntity(SecurityConstants.WX_GET_APPROVAL_DETAIL, formEntityDetail, String.class, accessToken).getBody();
if (Common.isEmpty(dataResultDetail)) {
throw new AuthenticationServiceException("获取企业微信招聘审批详情失败!");
}
jsonObject = JSON.parseObject(dataResultDetail);
errcode = jsonObject.getString("errcode");
errmsg = jsonObject.getString("errmsg");
if (!"0".equals(errcode)) {
return R.failed(errmsg);
}
// 详细信息
info = jsonObject.getString("info");
this.setTStatisticsProjectReimburseDetailByZhaoPin(info, r, userMap);
if (i++ >= 600) {
// 企业微信频率限制:接口频率限制 600次/分钟
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
return new R<>(list);
}
/**
* @Description: 从企业微信-获取详情
* @Author: hgw
......@@ -399,7 +537,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
String errmsg;
String info;
for (EkpQiwiChuchai r : list) {
log.error("企业微信出差【"+i+"/"+""+list.size()+"】条");
log.error("企业微信出差【" + i + "/" + "" + list.size() + "】条");
jsonDetail = new JSONObject();
jsonDetail.put("sp_no", r.getFdSpNo());
formEntityDetail = new HttpEntity<>(jsonDetail.toString(), headers);
......@@ -517,11 +655,11 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
// 出差时长
//String newDuration;
// 出差地点级别
String addressLevel= null;
String addressLevel = null;
// 交通补助
String jiaoTong= null;
String jiaoTong = null;
// 餐饮补助
String canYin= null;
String canYin = null;
// 业务条线归属
//String lineType;
// 出差事由
......@@ -633,9 +771,9 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
int renShu1 = person.split(",").length;
int renShu2 = person.split(",").length;
if (renShu1 > renShu2) {
renShu +=renShu1;
renShu += renShu1;
} else {
renShu +=renShu2;
renShu += renShu2;
}
}
reimburse.setFdRenShu(renShu);
......@@ -649,4 +787,250 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
}
}
/**
* @param reimburse
* @Description: 向详情里塞值
* @Author: hgw
* @Date: 2024-4-12 17:01:35
* @return: void
**/
private void setTStatisticsProjectReimburseDetailByZhaoPin(String info, EkpQiwiZhaoPin reimburse, Map<String, String> userMap) {
JSONObject jsonObject = JSON.parseObject(info);
if (Common.isNotNull(info)) {
reimburse.setFdDataSource("企微");
reimburse.setCreateTime(LocalDateTime.now());
String userId = ((JSONObject) jsonObject.get("applyer")).getString("userid");
if (Common.isNotNull(userId) && userMap.get(userId) != null) {
reimburse.setFdApplyUserName(userMap.get(userId));
} else {
reimburse.setFdApplyUserName(userId);
}
reimburse.setFdApplyUserDept(((JSONObject) jsonObject.get("applyer")).getString("partyid"));
reimburse.setFdSpNo(jsonObject.getString("sp_no"));
reimburse.setFdApplyDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(String.valueOf(jsonObject.get("apply_time")))), ZoneId.systemDefault()));
// 核心数据
JSONObject applyData = (JSONObject) jsonObject.get("apply_data");
String contents = applyData.getString("contents");
List<HashMap> contentList = JSON.parseArray(contents, HashMap.class);
JSONArray title;
String titleStr;
JSONObject value;
JSONObject attendance;
// 开始时间
LocalDate newBegin = null;
// 结束时间
LocalDate newEnd = null;
// 申请子 (分) 公司或部门名称
String fdUserDeptName = null;
// "购买方式"
String fdBuyStyle = null;
// "平台名称"
String fdPingTaiName = null;
// "平台产品名称"
String fdPingTaiChanPin = null;
// "数量"
String fdNum = null;
// "单价"
String fdMoney = null;
// "总计金额"
String fdMoneySum = null;
// "使用项目名称"
String fdDeptName = null;
// "使用岗位名称"
String fdPostName = null;
// "成本归属"
String fdCostName = null;
// 招聘运营部填写
// "购买/调配方式是否合理")
String fdTwoIsHeLi = null;
// "平台名称"
String fdTwoPingTaiName = null;
// "产品名称"
String fdTwoPingTaiChanPin = null;
// "数量"
String fdTwoNum = null;
// "金额"
String fdTwoMoneySum = null;
// "被调配的业务单元名称"
String fdTwoYeWu = null;
// "备注"
String fdTwoRemark = null;
String keyText = "text";
String keyMoney = "new_money";
String keyNumber = "new_number";
String valueStr;
for (HashMap content : contentList) {
try {
title = (JSONArray) content.get("title");
titleStr = String.valueOf(((JSONObject) title.get(0)).get("text"));
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
valueStr = value.getString(keyText);
switch (titleStr) {
case "申请子 (分) 公司或部门名称":
fdUserDeptName = this.getDeptName(value);
break;
case "购买方式":
fdBuyStyle = this.getSelectValue(value);
break;
case "开始时间":
attendance = (JSONObject) value.get("date");
newBegin = LocalDate.ofEpochDay((Long.parseLong(attendance.getString("s_timestamp")) + 28801) / 86400);
break;
case "结束时间":
attendance = (JSONObject) value.get("date");
newEnd = LocalDate.ofEpochDay((Long.parseLong(attendance.getString("s_timestamp")) + 28801) / 86400);
break;
case "平台名称":
fdPingTaiName = valueStr;
break;
case "平台产品名称":
fdPingTaiChanPin = valueStr;
break;
case "数量":
fdNum = value.getString(keyNumber);
break;
case "单价":
fdMoney = value.getString(keyMoney);
break;
case "总计金额":
fdMoneySum = value.getString(keyMoney);
break;
case "使用项目名称":
fdDeptName = valueStr;
break;
case "使用岗位名称":
fdPostName = valueStr;
break;
case "成本归属":
fdCostName = this.getDeptName(value);
break;
case "招聘运营部填写":
JSONArray childrenArray = (JSONArray) value.get("children");
if (Common.isNotNull(childrenArray) && !childrenArray.isEmpty()) {
List<HashMap> childrenList = JSON.parseArray(((JSONObject) childrenArray.get(0)).getString("list"), HashMap.class);
for (HashMap childrenContent : childrenList) {
title = (JSONArray) childrenContent.get("title");
titleStr = String.valueOf(((JSONObject) title.get(0)).get("text"));
value = (JSONObject) childrenContent.get(VALUESTR);
if (Common.isNotNull(value)) {
valueStr = value.getString(keyText);
switch (titleStr) {
case "购买/调配方式是否合理":
fdTwoIsHeLi = this.getSelectValue(value);
if (Common.isEmpty(fdTwoIsHeLi)) {
fdTwoIsHeLi = "无";
}
break;
case "平台名称":
fdTwoPingTaiName = valueStr;
break;
case "产品名称":
fdTwoPingTaiChanPin = valueStr;
break;
case "数量":
fdTwoNum = value.getString(keyText);
break;
case "金额":
fdTwoMoneySum = value.getString(keyMoney);
break;
case "被调配的业务单元名称":
fdTwoYeWu = valueStr;
break;
case "备注":
fdTwoRemark = valueStr;
break;
default:
break;
}
}
}
}
break;
default:
break;
}
}
} catch (Exception e) {
log.error("获取企微招聘平台信息出错:" + e.getMessage());
}
}
reimburse.setFdNewBegin(newBegin);
reimburse.setFdNewEnd(newEnd);
reimburse.setFdUserDeptName(fdUserDeptName);
reimburse.setFdBuyStyle(fdBuyStyle);
reimburse.setFdPingTaiName(fdPingTaiName);
reimburse.setFdPingTaiChanPin(fdPingTaiChanPin);
reimburse.setFdNum(fdNum);
reimburse.setFdMoney(fdMoney);
reimburse.setFdMoneySum(fdMoneySum);
reimburse.setFdDeptName(fdDeptName);
reimburse.setFdPostName(fdPostName);
reimburse.setFdCostName(fdCostName);
reimburse.setFdTwoIsHeLi(fdTwoIsHeLi);
reimburse.setFdTwoPingTaiName(fdTwoPingTaiName);
reimburse.setFdTwoPingTaiChanPin(fdTwoPingTaiChanPin);
reimburse.setFdTwoNum(fdTwoNum);
reimburse.setFdTwoMoneySum(fdTwoMoneySum);
reimburse.setFdTwoYeWu(fdTwoYeWu);
reimburse.setFdTwoRemark(fdTwoRemark);
}
}
/**
* @Description: 获取选择框的值
* @Author: hgw
* @Date: 2024/8/27 14:57
* @return: java.lang.String
**/
private String getSelectValue(JSONObject value) {
JSONObject options0value0;
JSONArray options;
JSONObject options0;
JSONArray options0value;
JSONObject selector;
if (Common.isNotNull(value)) {
selector = (JSONObject) value.get("selector");
if (Common.isNotNull(selector)) {
options = (JSONArray) selector.get("options");
if (Common.isNotNull(options)) {
options0 = (JSONObject) options.get(0);
if (Common.isNotNull(options0)) {
options0value = (JSONArray) options0.get(VALUESTR);
if (Common.isNotNull(options0value)) {
options0value0 = (JSONObject) options0value.get(0);
if (Common.isNotNull(options0value0)) {
return options0value0.getString("text");
}
}
}
}
}
}
return null;
}
/**
* @Description: 获取部门名称
* @Author: hgw
* @Date: 2024/8/27 14:54
* @return: java.lang.String
**/
private String getDeptName(JSONObject value) {
JSONObject options0;
JSONArray options;
if (Common.isNotNull(value)) {
options = (JSONArray) value.get("departments");
if (Common.isNotNull(options)) {
options0 = (JSONObject) options.get(0);
if (Common.isNotNull(options0)) {
return options0.getString("name");
}
}
}
return null;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.permission.mapper.EkpQiweiZhaopinMapper">
<resultMap id="ekpQiweiZhaopinMap" type="com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiZhaoPin">
<id property="fdId" column="FD_ID"/>
<result property="fdSpNo" column="FD_SP_NO"/>
<result property="fdApplyUserName" column="FD_APPLY_USER_NAME"/>
<result property="fdApplyUserDept" column="FD_APPLY_USER_DEPT"/>
<result property="fdApplyDate" column="FD_APPLY_DATE"/>
<result property="fdNewBegin" column="FD_NEW_BEGIN"/>
<result property="fdNewEnd" column="FD_NEW_END"/>
<result property="fdStatus" column="FD_STATUS"/>
<result property="fdSettleFormId" column="FD_SETTLE_FORM_ID"/>
<result property="fdSettleFormNo" column="FD_SETTLE_FORM_NO"/>
<result property="createTime" column="create_time"/>
<result property="fdDataSource" column="FD_DATA_SOURCE"/>
<result property="fdUserDeptName" column="FD_USER_DEPT_NAME"/>
<result property="fdBuyStyle" column="FD_BUY_STYLE"/>
<result property="fdPingTaiName" column="FD_PING_TAI_NAME"/>
<result property="fdPingTaiChanPin" column="FD_PING_TAI_CHAN_PIN"/>
<result property="fdNum" column="FD_NUM"/>
<result property="fdMoney" column="FD_MONEY"/>
<result property="fdMoneySum" column="FD_MONEY_SUM"/>
<result property="fdDeptName" column="FD_DEPT_NAME"/>
<result property="fdPostName" column="FD_POST_NAME"/>
<result property="fdCostName" column="FD_COST_NAME"/>
<result property="fdTwoIsHeLi" column="FD_TWO_IS_HE_LI"/>
<result property="fdTwoPingTaiName" column="FD_TWO_PING_TAI_NAME"/>
<result property="fdTwoPingTaiChanPin" column="FD_TWO_PING_TAI_CHAN_PIN"/>
<result property="fdTwoNum" column="FD_TWO_NUM"/>
<result property="fdTwoMoneySum" column="FD_TWO_MONEY_SUM"/>
<result property="fdTwoYeWu" column="FD_TWO_YE_WU"/>
<result property="fdTwoRemark" column="FD_TWO_REMARK"/>
</resultMap>
<sql id="Base_Column_List">
a.FD_ID,
a.FD_SP_NO,
a.FD_APPLY_USER_NAME,
a.FD_APPLY_USER_DEPT,
a.FD_APPLY_DATE,
a.FD_NEW_BEGIN,
a.FD_NEW_END,
a.FD_STATUS,
a.FD_SETTLE_FORM_ID,
a.FD_SETTLE_FORM_NO,
a.create_time,
a.FD_DATA_SOURCE,
a.FD_USER_DEPT_NAME,
a.FD_BUY_STYLE,
a.FD_PING_TAI_NAME,
a.FD_PING_TAI_CHAN_PIN,
a.FD_NUM,
a.FD_MONEY,
a.FD_MONEY_SUM,
a.FD_DEPT_NAME,
a.FD_POST_NAME,
a.FD_COST_NAME,
a.FD_TWO_IS_HE_LI,
a.FD_TWO_PING_TAI_NAME,
a.FD_TWO_PING_TAI_CHAN_PIN,
a.FD_TWO_NUM,
a.FD_TWO_MONEY_SUM,
a.FD_TWO_YE_WU,
a.FD_TWO_REMARK
</sql>
<!--获取全部的,用来: 拉取企业微信时,不覆盖数据 -->
<select id="getZhaoPinAllInfo" resultMap="ekpQiweiZhaopinMap">
SELECT
<include refid="Base_Column_List"/>
FROM ekp_qiwei_zhaopin a
<where>
1=1
<if test="status != null and status.trim() != ''">
AND a.FD_STATUS = #{status}
</if>
</where>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment