Commit 0bd44101 authored by fangxinjiang's avatar fangxinjiang

社保自动化配置-fxj

parent 63c86599
...@@ -1330,8 +1330,8 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri ...@@ -1330,8 +1330,8 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
try { try {
// 添加了异常处理,避免 recordBase 不是合法数字格式时程序崩溃 // 添加了异常处理,避免 recordBase 不是合法数字格式时程序崩溃
if (CommonConstants.ZERO_STRING.equals(rel.getPaymentType())){ if (CommonConstants.ZERO_STRING.equals(rel.getPaymentType())){
if (BigDecimal.valueOf(Double.valueOf(rel.getRecordBase())).compareTo(setInfo.getLowerLimit()) != 0) { if (BigDecimal.valueOf(Double.valueOf(rel.getRecordBase())).compareTo(setInfo.getLowerLimit()) > 0) {
return R.failed("备案基数不于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerLimit()); return R.failed("备案基数不于配置名称("+rel.getConfigName()+")最低基数:"+setInfo.getLowerLimit());
} }
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
......
...@@ -42,17 +42,23 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo ...@@ -42,17 +42,23 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo
String corpSecret = "16kqEL_eU-ARwYyqLgEBWHgxm8gXVnkzv_eJMLy9NpU"; String corpSecret = "16kqEL_eU-ARwYyqLgEBWHgxm8gXVnkzv_eJMLy9NpU";
String docId = "dcTSMCj4lWV9MEP7lquZacOY8WS4g-iHxP_jVYA02tdYwb2YYc3BpDR8NrFWkEngHUg8abET4eTIpo9Zv-571NEA"; String docId = "dcTSMCj4lWV9MEP7lquZacOY8WS4g-iHxP_jVYA02tdYwb2YYc3BpDR8NrFWkEngHUg8abET4eTIpo9Zv-571NEA";
//智能表格发票数据表ID //智能表格发票数据表ID
String sheetId = "q979lj"; String[] sheetIds = new String[]{"q979lj","JdsXE8", "nyaxYZ" ,"lbzy8S"};
String sheetId;
String accessToken = weComSmartSheetManager.getAccessToken(corpId,corpSecret); String accessToken = weComSmartSheetManager.getAccessToken(corpId,corpSecret);
if (accessToken == null || accessToken.isEmpty()) { if (accessToken == null || accessToken.isEmpty()) {
log.error("获取access_token失败"); log.error("获取access_token失败");
return; return;
} }
int batchSize = 1000; int batchSize = 1000;
int batchCount = 0; int batchCount = 0;
String[] monthRange =null; String[] monthRange =null;
List<Map<String, Object>> records = new ArrayList<>(); List<Map<String, Object>> records = new ArrayList<>();
List<Map<String, Object>> tempRecords = null; List<Map<String, Object>> tempRecords = null;
int totalInserted = 0; // 记录已插入的总数据量
int sheetIndex = 0; // 当前使用的sheetId索引
sheetId = sheetIds[sheetIndex]; // 初始化使用第一个sheetId
//List<String> strings = new ArrayList<>(); //List<String> strings = new ArrayList<>();
//strings.add("FeiTaiLang_Fang"); //strings.add("FeiTaiLang_Fang");
//strings.add("ZhangQianQian"); //strings.add("ZhangQianQian");
...@@ -62,8 +68,8 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo ...@@ -62,8 +68,8 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo
log.info("微信智能表格发票数据删除完成"); log.info("微信智能表格发票数据删除完成");
log.info("微信智能表格发票数据插入开始..."); log.info("微信智能表格发票数据插入开始...");
//获取最近24个月的发票信息,按月去插入到智能表格中 //获取最近24个月的发票信息,按月去插入到智能表格中
for (int i = 0; i < 24; i++){
monthRange = MonthCalculationUtils.calculateMonthRange(0); monthRange = MonthCalculationUtils.calculateMonthRange(i);
if (null != monthRange && monthRange.length == CommonConstants.dingleDigitIntArray[2]){ if (null != monthRange && monthRange.length == CommonConstants.dingleDigitIntArray[2]){
records = baseMapper.selectInvoiceList(monthRange[0],monthRange[1]); records = baseMapper.selectInvoiceList(monthRange[0],monthRange[1]);
} }
...@@ -77,11 +83,33 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo ...@@ -77,11 +83,33 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo
for (int j = 0; j < batchCount; j++) { for (int j = 0; j < batchCount; j++) {
tempRecords = records.subList(j * batchSize, Math.min((j + 1) * batchSize, records.size())); tempRecords = records.subList(j * batchSize, Math.min((j + 1) * batchSize, records.size()));
// 检查是否需要切换到下一个sheetId
if (totalInserted + tempRecords.size() > 100000) {
// 如果当前数据加上已插入数据超过100000,则切换到下一个sheetId
sheetIndex++;
if (sheetIndex < sheetIds.length) {
sheetId = sheetIds[sheetIndex];
totalInserted = 0; // 重置计数器
log.info("切换到下一个表格,使用sheetId: " + sheetId);
// 删除新表格中的所有数据
log.info("清空新表格数据开始...");
weComSmartSheetManager.deleteAllRows(accessToken, docId, sheetId);
log.info("清空新表格数据完成");
} else {
log.warn("sheetIds已用完,无法继续插入数据");
return;
}
}
debugService.debugInsertIssueAsso(accessToken,tempRecords,docId,sheetId); debugService.debugInsertIssueAsso(accessToken,tempRecords,docId,sheetId);
break; totalInserted += tempRecords.size();
} }
} }
log.info("微信智能表格发票数据插入完成"); }
log.info("微信智能表格发票数据插入完成,总共插入记录数: " + totalInserted);
//智能表格合同数据表ID //智能表格合同数据表ID
/*sheetId = "EuVt8X"; /*sheetId = "EuVt8X";
log.info("微信智能表格合同数据删除开始..."); log.info("微信智能表格合同数据删除开始...");
......
...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.ekp.config.WxConfig; import com.yifu.cloud.plus.v1.ekp.config.WxConfig;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.jasypt.commons.CommonUtils;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -295,31 +296,33 @@ public class WeComSmartSheetDebugger { ...@@ -295,31 +296,33 @@ public class WeComSmartSheetDebugger {
for (Map.Entry<String, Object> entry : fieldData.entrySet()) { for (Map.Entry<String, Object> entry : fieldData.entrySet()) {
String fieldName = entry.getKey(); String fieldName = entry.getKey();
String fieldValue = entry.getValue().toString(); String fieldValue = entry.getValue().toString();
// 构造字段值格式[{"type": "text", "text": "文本内容"}]
JSONArray fieldValueArray = new JSONArray(); JSONArray fieldValueArray = new JSONArray();
JSONObject textObject = new JSONObject(); JSONObject textObject = new JSONObject();
//根据fieldMap 对应的字段类型 初始化对应的企业微信的字段 //根据fieldMap 对应的字段类型 初始化对应的企业微信的字段
if(fieldMap.containsKey(fieldName)){ if (fieldMap.containsKey(fieldName)) {
/* if (fieldMap.get(fieldName).equals("FIELD_TYPE_DATE_TIME")){ if (fieldMap.get(fieldName).equals("FIELD_TYPE_DATE_TIME")) {
textObject.put("type", "Date"); //时间格式转换,如果空则返回空,如果非空则转换为日期,然后返回时间戳字符串
textObject.put("text", fieldValue); if (fieldValue.isEmpty()){
}else if (fieldMap.get(fieldName).equals("FIELD_TYPE_NUMBER")){ fieldValue = "";
textObject.put("type", "double");
textObject.put("text", 11111.00);
}else { }else {
fieldValue = ""+DateUtil.stringToDate(fieldValue,DateUtil.ISO_EXPANDED_DATE_FORMAT).getTime();
}
values.put(fieldName, fieldValue);
} else if (fieldMap.get(fieldName).equals("FIELD_TYPE_NUMBER")) {
//如果是数字 字节转款,如果空或非数字 则返回0
if (fieldValue.isEmpty() || !fieldValue.matches("^[0-9]+(\\.[0-9]+)?$")) {
values.put(fieldName, 0);
}else {
values.put(fieldName, Double.valueOf(fieldValue));
}
} else {
textObject.put("type", "text"); textObject.put("type", "text");
textObject.put("text", fieldValue); textObject.put("text", fieldValue);
}*/
textObject.put("type", "text");
textObject.put("text", fieldValue);
}
fieldValueArray.add(textObject); fieldValueArray.add(textObject);
values.put(fieldName, fieldValueArray); values.put(fieldName, fieldValueArray);
} }
}
}
recordObj.put("values", values); recordObj.put("values", values);
recordsArray.add(recordObj); recordsArray.add(recordObj);
} }
......
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