|
|
|
@ -4,9 +4,7 @@ import cn.hutool.core.date.DatePattern; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
import com.dxhy.common.constant.DbConstant; |
|
|
|
|
import com.dxhy.common.datasource.config.DynamicContextHolder; |
|
|
|
|
import com.dxhy.common.enums.FplxEnum; |
|
|
|
@ -42,7 +40,6 @@ import java.math.BigDecimal; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 与山东能源交互数据主类 |
|
|
|
@ -91,18 +88,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
@Resource |
|
|
|
|
private TDxInvoiceReimburseDao invoiceReimburseDao; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private TdxRecordInvoiceDao tdxRecordInvoiceDao; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private TDxInvoiceReimburseService tDxInvoiceReimburseService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BaseTDxRecordInvoiceDetailDao baseTDxRecordInvoiceDetailDao; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private SysDeptDao sysDeptDao; |
|
|
|
|
|
|
|
|
@ -279,50 +270,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
return queryInvoiceResult; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getRecords(Map<String, Object> pramsMap) { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
QueryWrapper<TdxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
List<String> uuids = tdxRecordInvoiceDao.selectRecords(pramsMap); |
|
|
|
|
log.info("获取的uuid为{}",uuids); |
|
|
|
|
|
|
|
|
|
for (String uuid: uuids) { |
|
|
|
|
boolean flag = false; |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>(); |
|
|
|
|
detailWrapper.eq("uuid", uuid); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); |
|
|
|
|
List<BaseTDxRecordInvoiceDetail> details = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
|
|
log.info("获取到的明细为:{}",details); |
|
|
|
|
String taxRate = ""; |
|
|
|
|
for(BaseTDxRecordInvoiceDetail detail : details){ |
|
|
|
|
//获取明细信息 更新主表税率
|
|
|
|
|
if(StringUtils.isNotEmpty(detail.getTaxRate())){ |
|
|
|
|
if(flag){ |
|
|
|
|
if(!taxRate.contains(detail.getTaxRate())) { |
|
|
|
|
taxRate = taxRate + "," + detail.getTaxRate(); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
if(!taxRate.contains(detail.getTaxRate())) { |
|
|
|
|
taxRate = taxRate + detail.getTaxRate(); |
|
|
|
|
} |
|
|
|
|
flag = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("获取的数据明细taxRate为={}",taxRate); |
|
|
|
|
if(StringUtils.isNotEmpty(taxRate)) { |
|
|
|
|
Map<String, String> updateParam = new HashMap<>(); |
|
|
|
|
updateParam.put("taxRate", taxRate); |
|
|
|
|
updateParam.put("uuid", uuid); |
|
|
|
|
|
|
|
|
|
tdxRecordInvoiceDao.updateTaxRate(updateParam); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return "ok"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject singleCheckInvoice(Map<String, String> pramsMap) throws Exception { |
|
|
|
|
|
|
|
|
|
//1.封装查验参数
|
|
|
|
@ -512,20 +459,18 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
jsonObject.put("tonnage", invoiceData.get("dw")); |
|
|
|
|
jsonObject.put("limitPeople", invoiceData.get("xcrs")); |
|
|
|
|
String taxRate = ""; |
|
|
|
|
if (invoiceData.get("sl") == null || StringUtils.isBlank(invoiceData.get("sl").toString()) || |
|
|
|
|
"免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) { |
|
|
|
|
if (StringUtils.isBlank(invoiceData.get("sl").toString()) || "免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) { |
|
|
|
|
taxRate = "0"; |
|
|
|
|
jsonObject.put("taxRate", taxRate); |
|
|
|
|
} else { |
|
|
|
|
if (invoiceData.get("sl") != null && StringUtils.isNoneBlank(invoiceData.get("sl").toString())) { |
|
|
|
|
if (StringUtils.isNoneBlank(invoiceData.get("sl").toString())) { |
|
|
|
|
taxRate = invoiceData.get("sl").toString(); |
|
|
|
|
if (!"0".equals(taxRate)) { |
|
|
|
|
taxRate = "0." + taxRate; |
|
|
|
|
taxRate = taxRate.substring(0, taxRate.length() - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
taxRate = "0.000"; |
|
|
|
|
taxRate = "0"; |
|
|
|
|
} |
|
|
|
|
log.info("明细-发票税率为:{}", taxRate); |
|
|
|
|
jsonObject.put("taxRate", taxRate); |
|
|
|
@ -610,13 +555,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
|
} else { |
|
|
|
|
if (detail.get("sl") != null && StringUtils.isNoneBlank(detail.get("sl").toString())) { |
|
|
|
|
if (StringUtils.isNoneBlank(detail.get("sl").toString())) { |
|
|
|
|
taxRateDetail = detail.get("sl").toString(); |
|
|
|
|
if (!"0".equals(taxRateDetail)) { |
|
|
|
|
if (StringUtils.isNoneBlank(taxRateDetail)) { |
|
|
|
|
int index = taxRateDetail.indexOf("%"); |
|
|
|
|
if (index > 0) { |
|
|
|
|
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); |
|
|
|
|
// if (index > 0) {
|
|
|
|
|
// taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1);
|
|
|
|
|
// Float num = Float.parseFloat(taxRateDetail);
|
|
|
|
|
// if (num > 9) {
|
|
|
|
|
// taxRateDetail = "0." + taxRateDetail;
|
|
|
|
@ -625,7 +570,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
// taxRateDetail = "0.0" + taxRateDetail;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1255,23 +1200,23 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
if (invoiceInfo == null) { |
|
|
|
|
result = "发票信息不可为空"; |
|
|
|
|
} |
|
|
|
|
if (invoiceInfo.getInvoiceTypeCode() == null || "".equals(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
result = "发票类型不可为空"; |
|
|
|
|
} |
|
|
|
|
if (invoiceInfo.getInvoiceDate() == null || "".equals(invoiceInfo.getInvoiceDate())) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getInvoiceDate().toString())) { |
|
|
|
|
result = "开票日期不可为空"; |
|
|
|
|
} |
|
|
|
|
if (!CommonEnum.INV_ZZS_ELE_PP.equals(invoiceInfo.getInvoiceTypeCode()) && !CommonEnum.INV_ZZS_ELE_TXF.equals(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
if (invoiceInfo.getIdentityNumber() == null || "".equals(invoiceInfo.getIdentityNumber())) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getIdentityNumber())) { |
|
|
|
|
result = "用户证件号不可为空"; |
|
|
|
|
} |
|
|
|
|
if (invoiceInfo.getPassenger() == null || "".equals(invoiceInfo.getPassenger())) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getPassenger())) { |
|
|
|
|
result = "乘车人不可为空"; |
|
|
|
|
} |
|
|
|
|
if (invoiceInfo.getDepartCity() == null || invoiceInfo.getDepartCity().isEmpty()) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getDepartCity())) { |
|
|
|
|
result = "出发城市不可为空"; |
|
|
|
|
} |
|
|
|
|
if (invoiceInfo.getArriveCity() == null || invoiceInfo.getArriveCity().isEmpty()) { |
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getArriveCity())) { |
|
|
|
|
result = "到达城市不可为空"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|