release
路明慧 2 years ago
parent b464b0de43
commit 2754c94849
  1. 2
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/QueryDetailDataService.java
  2. 3
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/QueryDetailDataServiceImpl.java
  3. 34
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/RecordToQueryServiceImpl.java
  4. 2
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/VoucherRecordItemService.java
  5. 48
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/VoucherRecordItemServiceImpl.java

@ -16,4 +16,6 @@ public interface QueryDetailDataService extends IService<VoucherRecordQueryDetai
//插入主营业务收入数据
void insertZyDataToQueryDetail();
String[] getTime(String km);
}

@ -72,7 +72,8 @@ public class QueryDetailDataServiceImpl extends ServiceImpl<QueryDetailDataDao,
}
}
String[] getTime(String km){
@Override
public String[] getTime(String km){
//1.获取增量数据开始时间
Date beginTime = queryDetailDataDao.getBeginTime(km);
//2.第一次取原表时间

@ -6,10 +6,7 @@ import com.dxhy.core.dao.frTask.RecordToQueryDao;
import com.dxhy.core.enmu.KjkmTaxEnmu;
import com.dxhy.core.entity.frJob.FpTaxAmount;
import com.dxhy.core.entity.frJob.VoucherRecordQuery;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -44,6 +41,35 @@ public class RecordToQueryServiceImpl extends ServiceImpl<RecordToQueryDao, Vouc
public void getDataForFr() {
//清洗sap错误税率
voucherRecordItemService.refreshTax();
//开始插入进项科目数据
//1.获取时间
String[] time = getTime(JXZZS);
//2.查询数据
List<VoucherRecordQuery> voucherRecordQuerys =
recordToQueryDao.getDataFromRecordItems(time[0], time[1],JXZZS);
if (voucherRecordQuerys != null && voucherRecordQuerys.size() > 0){
//3.查询税率
Map<String, String> taxMap = KjkmTaxEnmu.getTaxMap();
//4.清洗税率
voucherRecordQuerys.forEach(v->{v.setSl(taxMap.get(v.getKjkmbh()));});
//5.报账单号去重
List<String> bzdhs
= voucherRecordQuerys.stream().map(VoucherRecordQuery::getBzdh)
.distinct().collect(Collectors.toList());
//6.根据报账单号获取发票税额
List<FpTaxAmount> taxAmounts = recordToQueryDao.getTaxAmount(bzdhs);
if (taxAmounts != null && taxAmounts.size()>0){
Map<String, String> amountMap = taxAmounts.stream().collect(Collectors.toMap(FpTaxAmount::getKey, FpTaxAmount::getFpse));
//7.添加税率
voucherRecordQuerys.forEach(v->v.setFpse(amountMap.get(v.getSl()+v.getBzdh())==null?"0":amountMap.get(v.getSl()+v.getBzdh())));
}
//8.保存或更新
this.saveOrUpdateBatch(voucherRecordQuerys);
}
}
@Override
@ -75,7 +101,7 @@ public class RecordToQueryServiceImpl extends ServiceImpl<RecordToQueryDao, Vouc
voucherRecordQuerys.forEach(v->v.setFpse(amountMap.get(v.getSl()+v.getBzdh())==null?"0":amountMap.get(v.getSl()+v.getBzdh())));
}
//8.保存或更新
this.saveOrUpdateBatch(voucherRecordQuerys);
boolean b = this.saveOrUpdateBatch(voucherRecordQuerys);
}
}

@ -4,5 +4,5 @@ import java.text.ParseException;
public interface VoucherRecordItemService {
void refreshTax();
boolean refreshTax();
}

@ -1,14 +1,12 @@
package com.dxhy.core.service.frJob;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dxhy.core.dao.frTask.QueryDetailDataDao;
import com.dxhy.core.dao.frTask.VoucherRecordItemDao;
import com.dxhy.core.enmu.KjkmTaxEnmu;
import com.dxhy.core.entity.frJob.VoucherRecordItemEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -16,22 +14,23 @@ import java.util.List;
import java.util.Map;
@Service("voucherRecordItemService")
@Slf4j
public class VoucherRecordItemServiceImpl extends ServiceImpl<VoucherRecordItemDao, VoucherRecordItemEntity> implements VoucherRecordItemService {
@Autowired
@Resource
private VoucherRecordItemDao voucherRecordItemDao;
@Autowired
private QueryDetailDataDao queryDetailDataDao;
@Resource
private QueryDetailDataService queryDetailDataService;
private static final String JXZZS = "22210101";
private static final String XXZZS = "22210102";
@Override
public void refreshTax(){
String[] jxTime = getTime(JXZZS);
public boolean refreshTax(){
try {
String[] jxTime = queryDetailDataService.getTime(JXZZS);
//查询进项数据
List<VoucherRecordItemEntity> jxVoucherRecordItems = voucherRecordItemDao.getByTime(jxTime[0], jxTime[1], JXZZS);
//税率枚举
@ -40,36 +39,19 @@ public class VoucherRecordItemServiceImpl extends ServiceImpl<VoucherRecordItemD
jxVoucherRecordItems.stream().forEach(e->e.setKbetr(taxMap.get(e.getRacct())));
this.updateBatchById(jxVoucherRecordItems);
}
String[] xxTime = getTime(XXZZS);
String[] xxTime = queryDetailDataService.getTime(XXZZS);
//查询销项数据
List<VoucherRecordItemEntity> xxVoucherRecordItems = voucherRecordItemDao.getByTime(xxTime[0], xxTime[1], XXZZS);
if (xxVoucherRecordItems != null && xxVoucherRecordItems.size() != 0){
xxVoucherRecordItems.stream().forEach(e->e.setKbetr(taxMap.get(e.getRacct())));
this.updateBatchById(xxVoucherRecordItems);
}
}
String[] getTime(String km){
//1.获取增量数据开始时间
Date beginTime = queryDetailDataDao.getBeginTime(km);
//2.第一次取原表时间
if (beginTime == null){
beginTime = queryDetailDataDao.getBeginTimefromRecord();
}catch (Exception e){
e.printStackTrace();
log.error("税率刷新时错误信息为{}",e.getMessage());
return false;
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//3.时间转换求结束日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(beginTime);
calendar.add(Calendar.DAY_OF_MONTH,-1);
//4.开始时间减一天
String begin = format.format(calendar.getTime());
//5.结束时间为现在加一天
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,1);
String end = format.format(calendar.getTime());
String[] time = {begin,end};
return time;
return true;
}
}

Loading…
Cancel
Save