提交 e963e2eb authored 作者: 李秋林's avatar 李秋林

导入飞书表格数据源【temporary_activity_reported】SQL查询切换

上级 2f4c3a01
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<groupId>com.wangxiaolu</groupId> <groupId>com.wangxiaolu</groupId>
<artifactId>wangxiaolu-export</artifactId> <artifactId>wangxiaolu-export</artifactId>
<version>0.0.1</version> <version>0.0.2</version>
<name>wangxiaolu-export</name> <name>wangxiaolu-export</name>
<description>wangxiaolu-export</description> <description>wangxiaolu-export</description>
......
package com.wangxiaolu.export.controller.feishu; package com.wangxiaolu.export.controller.feishu;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityClockDO; import com.wangxiaolu.export.mapper.entity.TemporaryActivityClockDO;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityPhotoDO; import com.wangxiaolu.export.mapper.entity.TemporaryActivityPhotoDO;
import com.wangxiaolu.export.mapper.entity.TemporaryActivityReportedDO; import com.wangxiaolu.export.mapper.entity.TemporaryActivityReportedDO;
...@@ -8,10 +10,8 @@ import com.wangxiaolu.export.service.ActivityToFeishuSheetService; ...@@ -8,10 +10,8 @@ import com.wangxiaolu.export.service.ActivityToFeishuSheetService;
import com.wangxiaolu.export.service.PromotionActivityService; import com.wangxiaolu.export.service.PromotionActivityService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -65,4 +65,37 @@ public class ActivityToFeishuSheet { ...@@ -65,4 +65,37 @@ public class ActivityToFeishuSheet {
log.info("============== 活动记录上传飞书 end(" + System.currentTimeMillis() + ") =============="); log.info("============== 活动记录上传飞书 end(" + System.currentTimeMillis() + ") ==============");
} }
@GetMapping("/feishu/yesterday_sheet")
public void yesterdayActivityList(){
log.info("============== 活动记录上传飞书 start ==============");
/**
* 1>> 查询前一天的活动记录
*/
String yt = DateUtil.format(DateUtil.yesterday(), DatePattern.NORM_DATE_PATTERN);
List<TemporaryActivityReportedDO> reportedDos = promotionActivityService.findActivityListByCreateDate(yt);
if (CollectionUtils.isEmpty(reportedDos)){
log.info("无活动记录,停止上传");
}
log.info("应上传飞书{}条活动记录",reportedDos.size());
List<Long> activityId = reportedDos.stream().map(TemporaryActivityReportedDO::getId).collect(Collectors.toList());
Map<Long, List<TemporaryActivityPhotoDO>> activityPhotos = promotionActivityService.findActivityPhotos(activityId);
/**
* 2>> 查询打卡记录
*/
List<TemporaryActivityClockDO> clockPhoto = promotionActivityService.findClockPhotoByCreateDate(yt);
Map<String, List<TemporaryActivityPhotoDO>> clockPhotoMap = new HashMap<>();
clockPhoto.stream().forEach(cp -> {
clockPhotoMap.put(cp.getTemporaryId() + "-" + cp.getCreateDate(), cp.getPhotoList());
});
activityToFeishuSheetService.activityDataToFeishuSheet(reportedDos,activityPhotos,clockPhotoMap);
log.info("============== 活动记录上传飞书 end ==============");
}
} }
...@@ -43,23 +43,45 @@ ...@@ -43,23 +43,45 @@
</select> </select>
<select id="findListByCreateDate" resultMap="BaseResultMap"> <select id="findListByCreateDate" resultMap="BaseResultMap">
select ar.id, select id,
ar.temporary_id, temporary_id,
ar.approver_id, approver_id,
ar.temporary_name, temporary_name,
ar.approve_name, approve_name,
ar.city, city,
ar.create_date, create_date,
ar.store_id, store_name,
ar.store_name, activity_pattern,
ar.activity_pattern, approve_status,
ar.approve_status, line_name,
ps.line_name, dept_qc_org_name as org_name
qd.org_name from temporary_activity_reported
from temporary_activity_reported ar where create_date = #{dateStr}
left join promotion_store ps on ar.store_id = ps.id and is_delete = 1
left join qince_employee qe on ar.approver_id = qe.qc_id and (dept_qc_org_name like '%战区' or dept_qc_org_name = '重客运营部')
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> </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>-->
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论