diff --git a/dxhy-base/src/main/java/com/dxhy/base/controller/BaseInvoiceController.java b/dxhy-base/src/main/java/com/dxhy/base/controller/BaseInvoiceController.java index 3767281e..1e7d121c 100644 --- a/dxhy-base/src/main/java/com/dxhy/base/controller/BaseInvoiceController.java +++ b/dxhy-base/src/main/java/com/dxhy/base/controller/BaseInvoiceController.java @@ -874,18 +874,40 @@ public class BaseInvoiceController extends AbstractController { String menuId = (String)map.get("menuId"); String company = (String)map.get("company"); + int curr = 0; + if (map.get("curr") != null){ + curr = (int) map.get("curr"); + }else { + ResponseEntity.ok(R.error("分页数据不能为空")); + } + + int size = 0; + if (map.get("size")!= null){ + size = (int) map.get("size"); + }else { + ResponseEntity.ok(R.error("分页大小不能为空")); + } + + + if (StringUtils.isNotBlank(inAccountStatus)){ if (StringUtils.isBlank(inAccountStatus)){ return ResponseEntity.ok(R.error("入账状态不能为空")); } - if (StringUtils.isBlank(maxTax)){ + if (StringUtils.isNotBlank(maxTax)){ return ResponseEntity.ok(R.error("税额上限不能为空")); } try { BigDecimal tax = new BigDecimal(maxTax); } catch (NumberFormatException e) { - return ResponseEntity.ok(R.error("输入税额上线格式不对,请重新输入")); + return ResponseEntity.ok(R.error("输入税额上限格式不对,请重新输入")); + } + + String allIn = "88"; + + if (map.get("sign") != null && "99".equals((String)map.get("sign"))){ + allIn = "99"; } @@ -924,6 +946,9 @@ public class BaseInvoiceController extends AbstractController { pramsMap.put("menuId", menuId); pramsMap.put("menuId", "118061"); pramsMap.put("maxTax",maxTax); + pramsMap.put("sign",allIn); + pramsMap.put("curr",curr); + pramsMap.put("size",size); pramsMap.put("business", getUserInfo().getBusiness()); pramsMap.put("dbName", getUserInfo().getDbName()); List taxList = getUserInfo().getOrg(); @@ -935,6 +960,8 @@ public class BaseInvoiceController extends AbstractController { } else { gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg()); } + + if (ObjectUtils.isNotEmpty(gfshList)){ pramsMap.put("gfsh", gfshList); }else { diff --git a/dxhy-base/src/main/java/com/dxhy/base/service/invoicecheck/BaseInvoiceManualCheckServiceImpl.java b/dxhy-base/src/main/java/com/dxhy/base/service/invoicecheck/BaseInvoiceManualCheckServiceImpl.java index d327a680..953def8a 100644 --- a/dxhy-base/src/main/java/com/dxhy/base/service/invoicecheck/BaseInvoiceManualCheckServiceImpl.java +++ b/dxhy-base/src/main/java/com/dxhy/base/service/invoicecheck/BaseInvoiceManualCheckServiceImpl.java @@ -225,9 +225,9 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl snDetailMap = new HashMap(); snDetailMap.put("rowNo", i + 1 + ""); snDetailMap.put("commodityCode", detail.getString("goodsNum")); @@ -601,18 +606,13 @@ public class SDNYMainProcessController extends AbstractController { } else { object.setZFILED5(environment); } -// object.setZFILED5(environment); + List sapInvoiceInfos = new ArrayList<>(); if (invoiceInfoList != null && invoiceInfoList.size() > 0) { for (SNInvoice invoice : invoiceInfoList) { String fplxdm = ""; String snFplx = ""; -// if (invoice.getPurchaserTaxNo() == null || "".equals(invoice.getPurchaserTaxNo())){ -// invoice.setPurchaserTaxNo(taxno); -// } -// if (invoice.getPurchaserName() == null || "".equals(invoice.getPurchaserName())){ -// invoice.setPurchaserName(taxname); -// } + result = snPushCheckRecordService.updateInvoicePoll(company, taxno, reimburse, invoice, fplxdm, imageId, compCode); //价税分离判断 diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java index d77173f5..6b0cd5df 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java @@ -10,6 +10,8 @@ import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.enums.FplxEnum; import com.dxhy.common.enums.SNFplxEnum; import com.dxhy.common.util.InvoiceUtil; +import com.dxhy.common.util.StringHelper; +import com.dxhy.common.utils.R; import com.dxhy.common.vo.UserInfo; import com.dxhy.erp.dao.*; import com.dxhy.erp.entity.*; @@ -29,6 +31,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -94,6 +97,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Resource private SysDeptDao sysDeptDao; + @Resource + private SNPushCheckRecordService snPushCheckRecordService; + + @Resource + private SignSaveInvoiceInfoService signSaveInvoiceInfoService; + @Resource private TdxPlatformCheckLogService platformCheckLogService; @@ -450,7 +459,8 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { jsonObject.put("tonnage", invoiceData.get("dw")); jsonObject.put("limitPeople", invoiceData.get("xcrs")); String taxRate = ""; - if ("免税".equals(invoiceData.get("sl"))) { + 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())) { taxRate = "0"; jsonObject.put("taxRate", taxRate); } else { @@ -613,14 +623,19 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice); log.info("进行价税分离的发票信息为:{}", invoiceInfo); ServiceResult invoiceResult = new ServiceResult<>(); + + boolean flag = false; //0523晚成伟提出新需求,客运汽车票必须实名才可以进行价税分离 - if(SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)){ - if(StringUtils.isEmpty(invoice.getRiderName()) || StringUtils.isEmpty(invoice.getIdcardNo())){ + if (SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)) { + if (StringUtils.isEmpty(invoice.getRiderName()) || StringUtils.isEmpty(invoice.getIdcardNo())) { log.info("非实名的实名客票 不需要做价税分离"); + flag = true; + invoiceResult.setMsg("ok"); + invoiceResult.setResult(true); } - invoiceResult.setMsg("ok"); - invoiceResult.setResult(true); - }else { + } + + if(!flag) { invoiceResult = this.valoremTaxCount(invoiceInfo, "Y"); InvoiceInfo data = invoiceResult.getData(); if (data != null) { @@ -635,6 +650,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { } } + if (!"ok".equals(invoiceResult.getMsg()) && !"0000".equals(invoiceResult.getMsg())) { log.info("价税分离失败:{}", invoiceResult.getMsg()); return invoiceResult.getMsg(); @@ -673,6 +689,62 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { if ("01".equals(fplxdm) || "02".equals(fplxdm) || "03".equals(fplxdm) || "04".equals(fplxdm) || "08".equals(fplxdm) || "10".equals(fplxdm) || "11".equals(fplxdm) || "14".equals(fplxdm) || "15".equals(fplxdm) || "31".equals(fplxdm) || "32".equals(fplxdm)) { + DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); + String fpdm = invoice.getInvoiceCode(); + String fphm = invoice.getInvoiceNumber(); + + QueryWrapper recordWrapper = new QueryWrapper<>(); + if (StringUtils.isEmpty(fpdm)) { + recordWrapper.eq("uuid", fphm); + } else { + recordWrapper.eq("uuid", fpdm + fphm); + } + + BaseTDxRecordInvoice update = baseTDxRecordInvoiceDao.selectOne(recordWrapper); + Map pramsMap = new HashMap<>(); + JSONObject checkInvoiceResult = null; + + //如果提交的发票信息在底账库不存在,则重新补充查验,插入数据库中. + if (update == null) { + try { + //传入的参数为:{billingDate=2023-04-24, totalAmount=9708.74, purchaserTaxNo=91370000MA3RD38A9Q, invoiceNumber=02014197, invoiceType=10100, + // invoiceCode=3700222130, checkCode=} + pramsMap.put("invoiceCode", fpdm); + pramsMap.put("invoiceNumber", fphm); + if (StringUtils.isNotEmpty(invoice.getBillingDate())) { + String billingDate = invoice.getBillingDate().replaceAll("-", ""); + pramsMap.put("billingDate", billingDate); + } + if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){ + pramsMap.put("totalAmount", invoice.getAmountTax()); + }else{ + pramsMap.put("totalAmount", invoice.getTotalAmount()); + } + + pramsMap.put("purchaserTaxNo", invoice.getPurchaserTaxNo()); + if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){ + pramsMap.put("invoiceType", "21"); + }else { + pramsMap.put("invoiceType", invoice.getInvoiceType()); + } + + checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); + log.info("补充查验结果为:{}", checkInvoiceResult); + } catch (Exception e) { + e.printStackTrace(); + log.error("补充查验失败,errormsg:{}", e.getMessage()); + } + + if (!checkInvoiceResult.containsKey("code")) { + if (!checkInvoiceResult.containsKey("cyjg")) { + checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); + log.info("补充查验的结果为:{}", checkInvoiceResult); + signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, "", "1", "business"); + } + } + } + DynamicContextHolder.push(DbConstant.BASICS_WRITE); + //可查验发票,已入库,更新票池 Integer integer = this.pushInvoiceToRecordInvoice2(invoice, imageId, compCode); log.info("可查验发票,更新底账库完成"); @@ -718,8 +790,14 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { log.info("uuid={}", uuid); reimburse.setSelectId(uuid); - reimburse.setTaxRate(invoice.getTaxRate()); - reimburse.setTaxCode(getTaxCode(invoice.getTaxRate())); + if (StringHelper.isNotBlank(invoice.getTaxRate())) { + reimburse.setTaxRate(invoice.getTaxRate()); + reimburse.setTaxCode(getTaxCode(invoice.getTaxRate())); + } else { + reimburse.setTaxRate("0%"); + reimburse.setTaxCode(getTaxCode(reimburse.getTaxRate())); + } + reimburse.setIsDeduction(invoice.getIsDeductible()); if (StringUtils.isNoneBlank(reimburse.getInvoiceCode())) { diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java index dc16e642..e6a8e7ee 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java @@ -10,6 +10,8 @@ import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.enums.FplxEnum; import com.dxhy.common.enums.ReturnCodeEnum; import com.dxhy.common.service.impl.MpBaseServiceImpl; +import com.dxhy.common.util.DateOrderUtil; +import com.dxhy.common.util.StringHelper; import com.dxhy.common.util.pojo.Authorize; import com.dxhy.common.util.pojo.GlobalInfo; import com.dxhy.erp.dao.*; @@ -20,7 +22,11 @@ import com.dxhy.erp.service.InvoiceAuthService; import com.dxhy.erp.service.TDxInvoiceReimburseService; import com.dxhy.erp.utils.CheckUtils; import lombok.extern.slf4j.Slf4j; +import com.dxhy.erp.utils.DateUtil; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.joda.time.DateTime; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -29,6 +35,7 @@ import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.*; +import java.util.stream.Collectors; /** * @author dxhy @@ -341,7 +348,19 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl{}",zdata1.getZFPHM()); + String collect = fplxList.stream().collect(Collectors.joining(",")); + if(!collect.contains(convertFpzldm(zdata1.getZFPLX()))){ + log.info("非增值税先不处理:{}",JSON.toJSONString(zdata1)); + continue; + } + String fphm = zdata1.getZFPHM(); + if (org.apache.commons.lang3.StringUtils.isNotBlank(fphm) && fphm.length() > 8 && !("26".equals(zdata1.getZFPLX()) || "27".equals(zdata1.getZFPLX()))){ + fphm = fphm.replace(zdata1.getZFPDM(),""); + log.info("非全电但是号码"); + } + log.info("发票号码{}",fphm); + String uuid = zdata1.getZFPDM()+fphm; zdata1.setZFPLX(convertFpzldm(zdata1.getZFPLX())); TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); //查询票池 @@ -363,28 +382,21 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl 8 && !("26".equals(zdata1.getZFPLX()) || "27".equals(zdata1.getZFPLX()))){ + fphm = fphm.replace(zdata1.getZFPDM(),""); + log.info("非全电但是号码"); + } + log.info("发票号码{}",fphm); + String uuid = zdata1.getZFPDM()+fphm; //销项标识 String xxbs = zdata1.getXXBS(); - log.info("xxbs==>{}",xxbs); DynamicContextHolder.push("business"+DbConstant.BUSINESS_READ); - if(fplxList.contains(zdata1.getZFPLX()) && !"X".equals(xxbs)){ + if(fplxList.contains(zdata1.getZFPLX()) && !"X".equalsIgnoreCase(xxbs)){ TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); if(recordInvoiceByUuid!=null){ - UpdateWrapper updateWrapper = new UpdateWrapper(); - updateWrapper.eq("uuid",uuid); - //凭证号 - updateWrapper.set("sn_voucher_number",zdata1.getBELNR()); - //凭证过账日期 - updateWrapper.set("posting_time",zdata1.getBUDAT()); - //账期 - updateWrapper.set("account_period",zdata1.getBUDAT().substring(0,7)); - //报账单号 - updateWrapper.set("bzdh",zdata1.getZBZDH()); - //入账状态 - updateWrapper.set("inaccount_status",zdata1.getZYWZT()); - updateWrapper.set("comp_code",zdata1.getZGSDM()); - updateWrapper.set("bzr",zdata1.getZJBRT()); + UpdateWrapper updateWrapper = convertRecordInvoice(zdata1,uuid); DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE); int update = tDxrecordInvoiceDao.update(null, updateWrapper); if(update>0){ @@ -407,34 +419,13 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl> authStateList, Integer contentRows) { ReturnStateInfo run = new ReturnStateInfo(); if (contentRows == null || authStateList.size() != contentRows) { @@ -522,9 +532,26 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl map = Maps.newHashMap(); + map.put("1","3"); + try { + DateTime parse = DateTime.parse("0000-00-00"); + map.put("2","3"); + Date date1 = parse.toDate(); + String s = parse.toString("yyyy-MM-dd "); + System.out.println(""); + } catch (Exception e) { +// throw new RuntimeException(e); + } + map.put("3","3"); + System.out.println(); +// String d="2023"; +// String substring = d.substring(0, 7); +// System.out.println(substring); }