提交 62971ef5 authored 作者: 000516's avatar 000516 提交者: Coding

推送数据添加经销商、上下班信息

推送数据添加经销商、上下班信息
......@@ -40,29 +40,29 @@ public class ActivityToFeishuSheet {
*/
@PostMapping("/feishu/sheet")
public void activityList(@RequestBody ActivityVo activityVo) {
/**
* 1>> 查询活动记录
* 查询当天的记录
*/
List<TemporaryActivityReportedDO> reportedDos = promotionActivityService.findActivityList(activityVo);
List<Long> activityId = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityId);
/**
* 2>> 查询打卡记录
*/
List<TemporaryActivityClockDO> clockPhoto = promotionActivityService.findClockPhoto(activityVo);
Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap = new HashMap<>();
clockPhoto.stream().forEach(cp -> {
clockPhotoMap.put(cp.getTemporaryId() + "-" + cp.getCreateDate(), cp.getPhotoList());
});
log.info("============== 活动记录上传飞书 start(" + System.currentTimeMillis() + ") ==============");
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockPhotoMap);
log.info("============== 活动记录上传飞书 end(" + System.currentTimeMillis() + ") ==============");
//
// /**
// * 1>> 查询活动记录
// * 查询当天的记录
// */
// List<TemporaryActivityReportedDO> reportedDos = promotionActivityService.findActivityList(activityVo);
// List<Long> activityId = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
// Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityId);
//
// /**
// * 2>> 查询打卡记录
// */
// List<TemporaryActivityClockDO> clockPhoto = promotionActivityService.findClockPhoto(activityVo);
// Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap = new HashMap<>();
// clockPhoto.stream().forEach(cp -> {
// clockPhotoMap.put(cp.getTemporaryId() + "-" + cp.getCreateDate(), cp.getPhotoList());
// });
//
// log.info("============== 活动记录上传飞书 start(" + System.currentTimeMillis() + ") ==============");
//
// activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockPhotoMap);
//
// log.info("============== 活动记录上传飞书 end(" + System.currentTimeMillis() + ") ==============");
}
@GetMapping("/feishu/yesterday_sheet")
......@@ -75,17 +75,20 @@ public class ActivityToFeishuSheet {
List<TemporaryActivityReportedDO> reportedDos = promotionActivityService.findActivityListByCreateDate(yt);
log.info("应上传飞书{}条活动记录",reportedDos.size());
if (CollectionUtils.isEmpty(reportedDos)){
log.info("无活动记录,停止上传");
return;
}
log.info("应上传飞书{}条活动记录",reportedDos.size());
List<Long> activityId = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityId);
List<Long> activityIds = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityIds);
Map<Long, TemporaryActivityClockDO> clockMap = promotionActivityService.findClockInfoByActivityIds(activityIds);
/**
* 2>> 查询打卡记录
* 2>> 查询打卡图片
*/
List<TemporaryActivityClockDO> clockPhoto = promotionActivityService.findClockPhotoByCreateDate(yt);
Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap = new HashMap<>();
......@@ -94,7 +97,7 @@ public class ActivityToFeishuSheet {
});
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockPhotoMap);
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockMap,clockPhotoMap);
log.info("============== 活动记录上传飞书 end ==============");
}
......
......@@ -21,6 +21,8 @@ public interface TemporaryActivityClockMapper extends BaseMapper<TemporaryActivi
List<TemporaryActivityClockDO> findClockPhotoList(@Param("params") ActivityVo activityVo);
List<TemporaryActivityClockDO> findClockPhotoListByCreateDate(String dateStr);
List<TemporaryActivityClockDO> findClockListByActivityIds(@Param("activityIds") List<Long> activityId);
}
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
......@@ -16,7 +17,51 @@ import java.util.List;
public class TemporaryActivityClockDO implements Serializable {
private Long temporaryId;
private Long reportedId;
private String createDate;
/**
* 上班打卡地址
*/
private String clockInAddress;
/**
* 上班打卡时间
*/
private Date clockInTime;
/**
* 午休下班打卡地址
*/
private String noonClockOutAddress;
/**
* 午休下班打卡时间
*/
private Date noonClockOutTime;
/**
* 午休上班打卡地址
*/
private String noonClockInAddress;
/**
* 午休上班打卡时间
*/
private Date noonClockInTime;
/**
* 下班打卡地址
*/
private String clockOutAddress;
/**
* 下班打卡时间
*/
private Date clockOutTime;
private List<TemporaryActivityPhotoDO> photoList;
@TableField(exist = false)
......
......@@ -39,6 +39,8 @@ public class TemporaryActivityReportedDO implements Serializable {
@TableField(exist = false)
private String createDate;
private String dealerName;
@TableField(exist = false)
private String lineName;
......
package com.wangxiaolu.export.service;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityClockDO;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityPhotoDO;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityReportedDO;
......@@ -12,5 +13,5 @@ import java.util.Map;
* @describe :
*/
public interface ActivityToFeishuSheetService {
void activityDataToFeishuSheet(List<TemporaryActivityReportedDO> reportedDos, Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos, Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap);
void activityDataToFeishuSheet(List<TemporaryActivityReportedDO> reportedDos, Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos, Map<Long, TemporaryActivityClockDO> clockMap, Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap);
}
......@@ -29,5 +29,7 @@ public interface PromotionActivityService {
Map<Long, List<TemporaryActivityPhotoDO>> findActivityPhotos(List<Long> activityId);
Map<Long, TemporaryActivityClockDO> findClockInfoByActivityIds(List<Long> activityId);
List<TemporaryActivityClockDO> findClockPhotoByCreateDate(String dateStr);
}
......@@ -11,7 +11,6 @@ import com.wangxiaolu.export.service.PromotionActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -66,6 +65,13 @@ public class PromotionActivityServiceImpl implements PromotionActivityService {
return activityPhotoMap;
}
@Override
public Map<Long, TemporaryActivityClockDO> findClockInfoByActivityIds(List<Long> activityId) {
List<TemporaryActivityClockDO> clockList = temporaryActivityClockMapper.findClockListByActivityIds(activityId);
Map<Long, TemporaryActivityClockDO> clockMap = clockList.stream().collect(Collectors.toMap(TemporaryActivityClockDO::getReportedId, o -> o));
return clockMap;
}
@Override
public List<TemporaryActivityClockDO> findClockPhotoByCreateDate(String dateStr) {
List<TemporaryActivityClockDO> clockPhotoList = temporaryActivityClockMapper.findClockPhotoListByCreateDate(dateStr);
......
package com.wangxiaolu.export.util;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.common.util.NumberUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.net.ssl.HttpsURLConnection;
......@@ -31,6 +31,7 @@ public class FeishuSheetUtils {
private static final String TENANT_ACCESS_TOKEN_URL = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal";
private static final String VALUES_APPEND = "/values_append";
private static final String VALUES_IMAGE = "/values_image";
private static final String VALUES = "/values";
/**
* 追加一条记录
......@@ -66,6 +67,33 @@ public class FeishuSheetUtils {
return NumberUtils.matcherNum(tableRange.split(":")[1]);
}
public void updateData(String range, List<Object> datas, String sheetToken, String autoToken) {
try {
// 组装参数
Map<String, Map<String, Object>> bodyMap = new HashMap<>();
Map<String, Object> valueRange = new HashMap<>();
valueRange.put("range", range);
valueRange.put("values", Arrays.asList(datas));
bodyMap.put("valueRange", valueRange);
String bodyJson = JSONObject.toJSONString(bodyMap);
String result = HttpUtil.createRequest(Method.PUT,SHEET_URL + sheetToken + VALUES)
.auth("Bearer " + autoToken).contentType(CONTENT_TYPE)
.body(bodyJson)
.execute().body();
// 判断上传结果
JSONObject resultJson = JSONObject.parseObject(result);
int code = resultJson.getInteger("code");
if (code != 0) {
log.error("修改数据失败,修改表格位置:{},报错详情:\n{}", range, result);
}
} catch (Exception e) {
log.error("修改数据失败,修改表格位置:{}", range);
}
}
public void valuesImageToSheet(String range, String imageUrl, String sheetToken,String autoToken) {
if (StringUtils.isBlank(imageUrl) || !imageUrl.startsWith("https")) {
return;
......
......@@ -58,12 +58,13 @@ public class XxlJobHandler {
return;
}
List<Long> activityId = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
List<Long> activityIds = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityId);
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityIds);
Map<Long, TemporaryActivityClockDO> clockMap = promotionActivityService.findClockInfoByActivityIds(activityIds);
/**
* 2>> 查询打卡记录
* 2>> 查询打卡图片
*/
List<TemporaryActivityClockDO> clockPhoto = promotionActivityService.findClockPhotoByCreateDate(yt);
Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap = new HashMap<>();
......@@ -72,7 +73,7 @@ public class XxlJobHandler {
});
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockPhotoMap);
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockMap,clockPhotoMap);
log.info("============== 活动记录上传飞书 end ==============");
}
......
......@@ -3,6 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wangxiaolu.export.mapper.TemporaryActivityClockMapper">
<resultMap id="clockMap" type="com.wangxiaolu.export.mapper.entity.TemporaryActivityClockDO">
<result property="temporaryId" column="temporary_id" jdbcType="BIGINT"/>
<result property="createDate" column="create_date" jdbcType="VARCHAR"/>
......@@ -13,6 +14,22 @@
</resultMap>
<resultMap id="clockInfoMap" type="com.wangxiaolu.export.mapper.entity.TemporaryActivityClockDO">
<result property="temporaryId" column="temporary_id" jdbcType="BIGINT"/>
<result property="reportedId" column="reported_id" jdbcType="BIGINT"/>
<result property="createDate" column="create_date" jdbcType="VARCHAR"/>
<result property="clockInTime" column="clock_in_time" jdbcType="TIMESTAMP"/>
<result property="noonClockOutTime" column="noon_clock_out_time" jdbcType="TIMESTAMP"/>
<result property="noonClockInTime" column="noon_clock_in_time" jdbcType="TIMESTAMP"/>
<result property="clockOutTime" column="clock_out_time" jdbcType="TIMESTAMP"/>
<result property="clockInAddress" column="clock_in_address" jdbcType="VARCHAR"/>
<result property="noonClockOutAddress" column="noon_clock_out_address" jdbcType="VARCHAR"/>
<result property="noonClockInAddress" column="noon_clock_in_address" jdbcType="VARCHAR"/>
<result property="clockOutAddress" column="clock_out_address" jdbcType="VARCHAR"/>
</resultMap>
<select id="findClockPhotoList" resultMap="clockMap">
select ar.temporary_id temporary_id,
ar.create_date create_date,
......@@ -27,6 +44,19 @@
</select>
<!-- todo-->
<!-- <select id="findClockPhotoListByCreateDate" resultMap="clockMap">-->
<!-- select ar.temporary_id temporary_id,-->
<!-- ar.create_date create_date,-->
<!-- ap.type type,-->
<!-- ap.photo_url photo_url-->
<!-- from temporary_activity_reported ar-->
<!-- inner join temporary_activity_clock ac-->
<!-- on ar.temporary_id = ac.temporary_id and ar.create_date = ac.create_date-->
<!-- inner join temporary_activity_photo ap on ac.id = ap.clock_id-->
<!-- where ar.create_date = #{dateStr} and ap.is_delete = 1;-->
<!-- </select>-->
<select id="findClockPhotoListByCreateDate" resultMap="clockMap">
select ar.temporary_id temporary_id,
ar.create_date create_date,
......@@ -36,19 +66,31 @@
inner join temporary_activity_clock ac
on ar.temporary_id = ac.temporary_id and ar.create_date = ac.create_date
inner join temporary_activity_photo ap on ac.id = ap.clock_id
where ar.create_date = #{dateStr} and ap.is_delete = 1;
where ar.create_date LIKE '2024-10-%' and ap.is_delete = 1;
</select>
<!-- <select id="findClockPhotoListByCreateDate" resultMap="clockMap">-->
<!-- select ar.temporary_id temporary_id,-->
<!-- ar.create_date create_date,-->
<!-- ap.type type,-->
<!-- ap.photo_url photo_url-->
<!-- from temporary_activity_reported ar-->
<!-- inner join temporary_activity_clock ac-->
<!-- on ar.temporary_id = ac.temporary_id and ar.create_date = ac.create_date-->
<!-- inner join temporary_activity_photo ap on ac.id = ap.clock_id-->
<!-- where ar.create_date LIKE '2024-10-%' and ar.approver_id = '6477368280946792512' and ap.is_delete = 1;-->
<!-- </select>-->
<select id="findClockListByActivityIds" resultMap="clockInfoMap">
SELECT
reported_id,
clock_in_time,
clock_in_address,
noon_clock_out_time,
noon_clock_out_address,
noon_clock_in_time,
noon_clock_in_address,
clock_out_time,
clock_out_address
FROM
temporary_activity_clock tac
WHERE
reported_id in
<foreach collection="activityIds" item="activityId" open="(" close=")" separator=",">
#{activityId}
</foreach>
</select>
</mapper>
......@@ -14,6 +14,7 @@
<result property="city" column="city" jdbcType="VARCHAR"/>
<result property="approveName" column="approve_name" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" jdbcType="CHAR"/>
<result property="dealerName" column="dealer_name" jdbcType="VARCHAR"/>
<result property="lineName" column="line_name" jdbcType="VARCHAR"/>
<result property="orgName" column="org_name" jdbcType="VARCHAR"/>
</resultMap>
......@@ -42,25 +43,7 @@
ORDER BY ar.id;
</select>
<!-- <select id="findListByCreateDate" resultMap="BaseResultMap">-->
<!-- select id,-->
<!-- temporary_id,-->
<!-- approver_id,-->
<!-- temporary_name,-->
<!-- approve_name,-->
<!-- city,-->
<!-- create_date,-->
<!-- store_name,-->
<!-- activity_pattern,-->
<!-- approve_status,-->
<!-- line_name,-->
<!-- dept_qc_org_name as org_name-->
<!-- from temporary_activity_reported-->
<!-- where create_date LIKE '2024-10-%'-->
<!-- and is_delete = 1-->
<!-- and approver_id = '6477368280946792512'-->
<!-- </select>-->
<!-- todo 添加经销商名称:dealer_name-->
<select id="findListByCreateDate" resultMap="BaseResultMap">
select id,
temporary_id,
......@@ -69,37 +52,34 @@
approve_name,
city,
create_date,
dealer_name,
store_name,
activity_pattern,
approve_status,
line_name,
dept_qc_org_name as org_name
from temporary_activity_reported
where create_date = #{dateStr}
where create_date LIKE '2024-10-%'
and is_delete = 1
and (dept_qc_org_name like '%战区' or dept_qc_org_name = '重客运营部')
</select>
<!-- <select id="findListByCreateDate" resultMap="BaseResultMap">-->
<!-- select ar.id,-->
<!-- ar.temporary_id,-->
<!-- ar.approver_id,-->
<!-- ar.temporary_name,-->
<!-- ar.approve_name,-->
<!-- ar.city,-->
<!-- ar.create_date,-->
<!-- ar.store_id,-->
<!-- ar.store_name,-->
<!-- ar.activity_pattern,-->
<!-- ar.approve_status,-->
<!-- ps.line_name,-->
<!-- qd.org_name-->
<!-- from temporary_activity_reported ar-->
<!-- left join promotion_store ps on ar.store_id = ps.id-->
<!-- left join qince_employee qe on ar.approver_id = qe.qc_id-->
<!-- left join qince_department qd on qe.waiqin365_org_id = qd.qc_id-->
<!-- where ar.create_date = #{dateStr} and ar.is_delete = 1 and (qd.org_name like '%战区' or qd.org_name = '重客运营部')-->
<!-- select id,-->
<!-- temporary_id,-->
<!-- approver_id,-->
<!-- temporary_name,-->
<!-- approve_name,-->
<!-- city,-->
<!-- create_date,-->
<!-- store_name,-->
<!-- activity_pattern,-->
<!-- approve_status,-->
<!-- line_name,-->
<!-- dept_qc_org_name as org_name-->
<!-- from temporary_activity_reported-->
<!-- where create_date = #{dateStr}-->
<!-- and is_delete = 1-->
<!-- and (dept_qc_org_name like '%战区' or dept_qc_org_name = '重客运营部')-->
<!-- </select>-->
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论