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. 76
      dxhy-core/src/main/java/com/dxhy/core/service/frJob/VoucherRecordItemServiceImpl.java

@ -16,4 +16,6 @@ public interface QueryDetailDataService extends IService<VoucherRecordQueryDetai
//插入主营业务收入数据 //插入主营业务收入数据
void insertZyDataToQueryDetail(); 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.获取增量数据开始时间 //1.获取增量数据开始时间
Date beginTime = queryDetailDataDao.getBeginTime(km); Date beginTime = queryDetailDataDao.getBeginTime(km);
//2.第一次取原表时间 //2.第一次取原表时间

@ -6,10 +6,7 @@ import com.dxhy.core.dao.frTask.RecordToQueryDao;
import com.dxhy.core.enmu.KjkmTaxEnmu; import com.dxhy.core.enmu.KjkmTaxEnmu;
import com.dxhy.core.entity.frJob.FpTaxAmount; import com.dxhy.core.entity.frJob.FpTaxAmount;
import com.dxhy.core.entity.frJob.VoucherRecordQuery; 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 org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -44,6 +41,35 @@ public class RecordToQueryServiceImpl extends ServiceImpl<RecordToQueryDao, Vouc
public void getDataForFr() { public void getDataForFr() {
//清洗sap错误税率 //清洗sap错误税率
voucherRecordItemService.refreshTax(); 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 @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()))); voucherRecordQuerys.forEach(v->v.setFpse(amountMap.get(v.getSl()+v.getBzdh())==null?"0":amountMap.get(v.getSl()+v.getBzdh())));
} }
//8.保存或更新 //8.保存或更新
this.saveOrUpdateBatch(voucherRecordQuerys); boolean b = this.saveOrUpdateBatch(voucherRecordQuerys);
} }
} }

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

@ -1,14 +1,12 @@
package com.dxhy.core.service.frJob; package com.dxhy.core.service.frJob;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.dao.frTask.VoucherRecordItemDao;
import com.dxhy.core.enmu.KjkmTaxEnmu; import com.dxhy.core.enmu.KjkmTaxEnmu;
import com.dxhy.core.entity.frJob.VoucherRecordItemEntity; import com.dxhy.core.entity.frJob.VoucherRecordItemEntity;
import org.apache.commons.lang.StringUtils; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.ParseException; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -16,60 +14,44 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Service("voucherRecordItemService") @Service("voucherRecordItemService")
@Slf4j
public class VoucherRecordItemServiceImpl extends ServiceImpl<VoucherRecordItemDao, VoucherRecordItemEntity> implements VoucherRecordItemService { public class VoucherRecordItemServiceImpl extends ServiceImpl<VoucherRecordItemDao, VoucherRecordItemEntity> implements VoucherRecordItemService {
@Autowired @Resource
private VoucherRecordItemDao voucherRecordItemDao; private VoucherRecordItemDao voucherRecordItemDao;
@Autowired @Resource
private QueryDetailDataDao queryDetailDataDao; private QueryDetailDataService queryDetailDataService;
private static final String JXZZS = "22210101"; private static final String JXZZS = "22210101";
private static final String XXZZS = "22210102"; private static final String XXZZS = "22210102";
@Override @Override
public void refreshTax(){ public boolean refreshTax(){
String[] jxTime = getTime(JXZZS); try {
//查询进项数据 String[] jxTime = queryDetailDataService.getTime(JXZZS);
List<VoucherRecordItemEntity> jxVoucherRecordItems = voucherRecordItemDao.getByTime(jxTime[0], jxTime[1], JXZZS); //查询进项数据
//税率枚举 List<VoucherRecordItemEntity> jxVoucherRecordItems = voucherRecordItemDao.getByTime(jxTime[0], jxTime[1], JXZZS);
Map<String, String> taxMap = KjkmTaxEnmu.getTaxMap(); //税率枚举
if (jxVoucherRecordItems != null && jxVoucherRecordItems.size() != 0){ Map<String, String> taxMap = KjkmTaxEnmu.getTaxMap();
jxVoucherRecordItems.stream().forEach(e->e.setKbetr(taxMap.get(e.getRacct()))); if (jxVoucherRecordItems != null && jxVoucherRecordItems.size() != 0){
this.updateBatchById(jxVoucherRecordItems); 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){ List<VoucherRecordItemEntity> xxVoucherRecordItems = voucherRecordItemDao.getByTime(xxTime[0], xxTime[1], XXZZS);
xxVoucherRecordItems.stream().forEach(e->e.setKbetr(taxMap.get(e.getRacct()))); if (xxVoucherRecordItems != null && xxVoucherRecordItems.size() != 0){
this.updateBatchById(xxVoucherRecordItems); xxVoucherRecordItems.stream().forEach(e->e.setKbetr(taxMap.get(e.getRacct())));
} this.updateBatchById(xxVoucherRecordItems);
}
} }catch (Exception e){
e.printStackTrace();
String[] getTime(String km){ log.error("税率刷新时错误信息为{}",e.getMessage());
//1.获取增量数据开始时间 return false;
Date beginTime = queryDetailDataDao.getBeginTime(km);
//2.第一次取原表时间
if (beginTime == null){
beginTime = queryDetailDataDao.getBeginTimefromRecord();
} }
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 true;
return time;
} }
} }

Loading…
Cancel
Save