|
|
@ -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; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|