提交 bb5e5158 authored 作者: 000516's avatar 000516 提交者: Coding

飞书api配置[设置单元格样式]:axmr005战区数据同步飞书表格后,再次设置单元格样式将数字类型转换为日期类型[yyyy-MM-dd]

Merge Request: 飞书api配置[设置单元格样式]:axmr005战区数据同步飞书表格后,再次设置单元格样式将数字类型转换为日期类型[yyyy-MM-dd] Created By: @李秋林 Accepted By: @李秋林 URL: https://g-pkkp8204.coding.net/p/wangxiaolu-sfa/d/wangxiaolu-sfa-module-job/git/merge/120?initial=true
...@@ -29,12 +29,13 @@ public class ErpAxmr005ShippingDetailsDaoImpl implements ErpAxmr005ShippingDetai ...@@ -29,12 +29,13 @@ public class ErpAxmr005ShippingDetailsDaoImpl implements ErpAxmr005ShippingDetai
List<ErpAxmr005ShippingDetails> zhanquDataset = erpAxmr005ShippingDetailsMapper.getZhanquDataset(date); List<ErpAxmr005ShippingDetails> zhanquDataset = erpAxmr005ShippingDetailsMapper.getZhanquDataset(date);
List<Object> os = new ArrayList<>(); List<Object> os = new ArrayList<>();
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date); // date日期距离 1899 年 12 月 30 日的天数
float days = (int) ((date.getTime() - DateUtils.parseDate("1899-12-30").getTime()) / (1000 * 60 * 60 * 24));
for (ErpAxmr005ShippingDetails erpDo : zhanquDataset) { for (ErpAxmr005ShippingDetails erpDo : zhanquDataset) {
List<Object> data = new ArrayList<>(); List<Object> data = new ArrayList<>();
data.add(millis+"_"+erpDo.getId()); data.add(millis+"_"+erpDo.getId());
data.add(erpDo.getShippingOrderNumber()); data.add(erpDo.getShippingOrderNumber());
data.add(dateStr); data.add(days);
data.add(erpDo.getSalesDepartmentAbbr()); data.add(erpDo.getSalesDepartmentAbbr());
data.add(erpDo.getReceivingCustomerAbbr()); data.add(erpDo.getReceivingCustomerAbbr());
data.add(erpDo.getProductName()); data.add(erpDo.getProductName());
......
...@@ -9,5 +9,5 @@ import java.util.Date; ...@@ -9,5 +9,5 @@ import java.util.Date;
*/ */
public interface ErpAxmr005Service { public interface ErpAxmr005Service {
void axmr005ZQToFS(Date debitDate,Integer type); void axmr005ZQToFS(Date debitDate, Integer type);
} }
...@@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -38,15 +40,28 @@ public class ErpAxmr005ServiceImpl implements ErpAxmr005Service { ...@@ -38,15 +40,28 @@ public class ErpAxmr005ServiceImpl implements ErpAxmr005Service {
*/ */
String range = recordDto.getSheetId() + "!A:H"; String range = recordDto.getSheetId() + "!A:H";
JSONObject botToken1 = feiShuUtil.getBotToken1(); JSONObject botToken1 = feiShuUtil.getBotToken1();
String tenantAccessToken = botToken1.getString("tenant_access_token");
int batchSize = 100; int batchSize = 100;
for (int i = 0; i < zhanquDataset.size(); i+=batchSize) { for (int i = 0; i < zhanquDataset.size(); i+=batchSize) {
// 计算当前批次的结束位置 // 计算当前批次的结束位置
int end = Math.min(i + batchSize, zhanquDataset.size()); int end = Math.min(i + batchSize, zhanquDataset.size());
System.out.println(end); System.out.println(end);
List<Object> batch = zhanquDataset.subList(i, end); List<Object> batch = zhanquDataset.subList(i, end);
feiShuUtil.pushSetToSheet(range,batch,recordDto.getSheetToken(),botToken1.getString("tenant_access_token")); feiShuUtil.pushSetToSheet(range,batch,recordDto.getSheetToken(),tenantAccessToken);
} }
putDateFormatCell(recordDto,tenantAccessToken);
}
public void putDateFormatCell(FeishuSheetRecordDto recordDto,String tenantAccessToken) {
String range = recordDto.getSheetId() + "!C:C";
Map<String, Object> appendStyle = new HashMap<>();
Map<String, Object> style = new HashMap<>();
style.put("formatter", "yyyy-MM-dd");
appendStyle.put("range", range);
appendStyle.put("style", style);
Map<String, Object> body = new HashMap<>();
body.put("appendStyle", appendStyle);
feiShuUtil.appendStyle(recordDto.getSheetToken(),body,tenantAccessToken);
} }
} }
package com.sfa.job.util; package com.sfa.job.util;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
...@@ -17,7 +18,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -17,7 +18,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -48,6 +48,7 @@ public class FeiShuUtil { ...@@ -48,6 +48,7 @@ public class FeiShuUtil {
private static final String VALUES_APPEND = "/values_append"; private static final String VALUES_APPEND = "/values_append";
private static final String VALUES_IMAGE = "/values_image"; private static final String VALUES_IMAGE = "/values_image";
private static final String VALUES = "/values"; private static final String VALUES = "/values";
private static final String STYLE = "/style";
/** /**
...@@ -145,4 +146,12 @@ public class FeiShuUtil { ...@@ -145,4 +146,12 @@ public class FeiShuUtil {
} }
return resultJson; return resultJson;
} }
public void appendStyle(String sheetToken, Map<String, Object> body,String autoToken) {
// body上传
String result = HttpUtil.createRequest(Method.PUT,SHEET_URL + sheetToken + STYLE)
.auth("Bearer " + autoToken).contentType(CONTENT_TYPE)
.body(JSONObject.toJSONString(body))
.execute().body();
}
} }
...@@ -24,11 +24,11 @@ public class shippingTask { ...@@ -24,11 +24,11 @@ public class shippingTask {
/** /**
* 同步axmr005中t-1的数据到飞书表格 * 同步axmr005中t-1的数据到飞书表格
* 只同步线下战区数据、部分字段 * todo 只同步线下战区数据、部分字段
*/ */
@XxlJob("axmr005_zhanqu_days") @XxlJob("axmr005_zhanqu_days")
public void axmr005ZQByDays() { public void axmr005ZQByDays() {
Date date = DateUtils.addDays(new Date(), -1); Date date = DateUtils.addDays(new Date(), -5);
Integer type = FSRecordEnum.AXMR005_1.getType(); Integer type = FSRecordEnum.AXMR005_1.getType();
axmr005ZQToFSByDate(date,type); axmr005ZQToFSByDate(date,type);
} }
...@@ -41,7 +41,7 @@ public class shippingTask { ...@@ -41,7 +41,7 @@ public class shippingTask {
} }
private void axmr005ZQToFSByDate(Date date,Integer type) { private void axmr005ZQToFSByDate(Date date,Integer type) {
erpAxmr005Service.axmr005ZQToFS(date,type); erpAxmr005Service.axmr005ZQToFS(date, type);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论