diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java index ad3675ff..cf3e995d 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java @@ -106,11 +106,8 @@ public class SnEmailGatherTask { Store store = mailAuth(emailName, password); if(store == null){ MailGatherLogVo gatherLogVo = new MailGatherLogVo(); - gatherLogVo.setId(UUIDUtils.generateShortUuid()); - gatherLogVo.setErrorMsg("邮箱认证失败"); - gatherLogVo.setOcrType("1"); gatherLogVo.setFromAddress(emailName); - mailGatherLogService.insert(gatherLogVo); + buildMsg(gatherLogVo,"1","邮箱认证失败"); return; } Folder folder = store.getFolder("INBOX"); @@ -184,21 +181,19 @@ public class SnEmailGatherTask { Map resultMap = JSONObject.parseObject(body, Map.class); Object status = resultMap.get("status"); if(status != null && "200".equals(String.valueOf(status))){ - + buildMsg(gatherLogVo,"1","推送影像票夹成功"); }else { gatherLogVo.setFphm(""); - gatherLogVo.setOcrType("0"); - gatherLogVo.setErrorMsg("推送影像票夹失败"); - mailGatherLogService.insert(gatherLogVo); + buildMsg(gatherLogVo,"0","推送影像票夹失败"); break; } - System.out.println(body); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }else { log.debug("山能OCR识别失败------"); + buildMsg(gatherLogVo,"1","山能OCR识别失败"); } } } @@ -208,9 +203,7 @@ public class SnEmailGatherTask { } //进行数据插入 if(StringUtils.isNotBlank(gatherLogVo.getFpdm()) && StringUtils.isNotBlank(gatherLogVo.getFphm())){ - gatherLogVo.setOcrType("0"); - gatherLogVo.setErrorMsg("采集成功"); - mailGatherLogService.insert(gatherLogVo); + buildMsg(gatherLogVo,"0","采集成功"); }else { log.info("未采集到有效数据"); } @@ -228,6 +221,12 @@ public class SnEmailGatherTask { } } + public void buildMsg(MailGatherLogVo gatherLogVo, String type, String msg){ + gatherLogVo.setOcrType(type); + gatherLogVo.setErrorMsg(msg); + mailGatherLogService.insert(gatherLogVo); + } + public static Map convertToOcrResult(List openServiceOcrs, Map map,EmailMaintainVo maintainVo){ List resultToyxVoList = Lists.newArrayList(); Map hashMap = Maps.newHashMap(); diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index bb9acbb2..f5e57220 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -1,5 +1,6 @@ package com.dxhy.erp.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.dxhy.common.aspect.SysLog; import com.dxhy.common.constant.CommonConstants; @@ -70,7 +71,7 @@ public class SDNYMainProcessController extends AbstractController { @PostMapping("/sn/singleInvoiceCheck") @ResponseBody @SysLog("发票查验") - public ResponseEntity singleInvoiceCheck(@RequestBody Map pramsMap) { + public ResponseEntity singleInvoiceCheck(@RequestBody Map pramsMap) throws ParseException { log.info("传入的参数为:{}", pramsMap); String userid = "101833"; String dbName = "business"; @@ -128,6 +129,7 @@ public class SDNYMainProcessController extends AbstractController { log.info("发票类型为:{}", pramsMap.get("invoiceType")); String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); + log.info("uuid={}", uuid); String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); if (notes != null) { return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); @@ -136,18 +138,25 @@ public class SDNYMainProcessController extends AbstractController { //查询底账库是否有对应发票,有则直接返回 TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); if (checkInvoiceByUuid != null) { + log.info("进项票池已存在发票.直接返回票池信息"); R data = new R(1000, "default success"); - String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid); + JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); + convertToResult(checkInvoice); + data.put("data", checkInvoice); return ResponseEntity.ok(JSONObject.toJSONString(data)); } else { TdxSaleRecordInvoice tdxSaleRecordInvoice = tdxSaleRecordInvoiceDao.selectByUuid(uuid); + log.info("tdxSaleRecordInvoice={}", tdxSaleRecordInvoice); if (tdxSaleRecordInvoice != null) { + log.info("销项票池已存在发票.直接返回票池信息"); R data = new R(1000, "default success"); - String checkInvoice = JSONObject.toJSONString(tdxSaleRecordInvoice); + JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(tdxSaleRecordInvoice); + convertToResult(checkInvoice); + data.put("data", checkInvoice); return ResponseEntity.ok(JSONObject.toJSONString(data)); @@ -199,6 +208,136 @@ public class SDNYMainProcessController extends AbstractController { return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); } + private void convertToResult(JSONObject checkInvoice) throws ParseException { + checkInvoice.put("totalTax", checkInvoice.getString("taxAmount")); + checkInvoice.put("amountTax", checkInvoice.getString("totalAmount")); + checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount")); + String invoiceCode = checkInvoice.get("invoiceCode").toString(); + String invoiceType = checkInvoice.get("invoiceType").toString(); + if ("22".equals(invoiceType)) { + invoiceType = "33"; + } + if ("21".equals(invoiceType)) { + invoiceType = "31"; + } + + checkInvoice.put("invoiceType", invoiceType); + checkInvoice.put("administrativeDivisionNo", ""); + checkInvoice.put("administrativeDivisionName", ""); + + checkInvoice.put("invoiceCode", invoiceCode); + checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString()); + + String kprq = checkInvoice.get("invoiceDate").toString(); + Date formatDat = new SimpleDateFormat("yyyyMMdd").parse(kprq); + String str = new SimpleDateFormat("yyyy-MM-dd").format(formatDat); + log.info("开票日期为:{} ", str); + + checkInvoice.put("billingDate", str); + checkInvoice.put("purchaserName", checkInvoice.get("gfName")); + checkInvoice.put("purchaserTaxNo", checkInvoice.get("gfTaxNo")); + checkInvoice.put("purchaserBank", checkInvoice.get("gfBankAndNo")); + checkInvoice.put("purchaserAddressPhone", checkInvoice.get("gfAddressAndPhone")); + checkInvoice.put("salesName", checkInvoice.get("xfName")); + checkInvoice.put("salesTaxNo", checkInvoice.get("xfTaxNo")); + checkInvoice.put("salesAddressPhone", checkInvoice.get("gfAddressAndPhone")); + checkInvoice.put("salesBank", checkInvoice.get("gfBankAndNo")); + checkInvoice.put("checkCode", checkInvoice.get("checkCode")); + String taxRate = ""; + + List> returnDetailList = new ArrayList<>(); +// JSONArray detailList = (JSONArray) invoiceData.get("detailList"); + JSONArray detailList = new JSONArray(); + + for (int i = 0; i < detailList.size(); i++) { + String taxRateDetail = ""; + JSONObject detail = (JSONObject) detailList.get(i); + Map snDetailMap = new HashMap(); + snDetailMap.put("rowNo", i + 1 + ""); + snDetailMap.put("commodityCode", detail.getString("ssflbm")); + snDetailMap.put("commodityName", detail.getString("hwmc")); + snDetailMap.put("specificationModel", detail.getString("ggxh")); + snDetailMap.put("unit", detail.getString("jldw")); + String quantity = detail.getString("spsl"); + if (quantity.length() > 3) { + int index = quantity.indexOf("."); + quantity = quantity.substring(0, index + 2); + } + snDetailMap.put("quantity", quantity); + + String unitPrice = detail.getString("bhsdj"); + if (unitPrice.length() > 3) { + int index = unitPrice.indexOf("."); + unitPrice = unitPrice.substring(0, index + 3); + } + + snDetailMap.put("unitPrice", unitPrice); + + + if ("11".equals(invoiceType)) { + snDetailMap.put("tax", "0"); + + //如果是卷票计算合计金额 + Float hjje = null; + if (detail.getString("se") != null && detail.getString("je") != null) { + Float je = Float.parseFloat(detail.getString("je")); + Float se = Float.parseFloat(detail.getString("se")); + hjje = je + se; + } + + if (hjje != null) + snDetailMap.put("amount", hjje.toString()); + + } else { + snDetailMap.put("tax", "***".equals(detail.getString("se")) ? "0.00" : detail.getString("se")); + snDetailMap.put("amount", detail.getString("je")); + } + + + if ("免税".equals(detail.getString("sl"))) { + taxRateDetail = "0"; + snDetailMap.put("taxRate", taxRateDetail); + } else { + if (detail.get("sl") != null && 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); + Float num = Float.parseFloat(taxRateDetail); + if (num > 9) { + taxRateDetail = "0." + taxRateDetail; + } else { + if (!taxRateDetail.startsWith("0")) { + taxRateDetail = "0.0" + taxRateDetail; + } + } + } + } + } + + if ("11".equals(invoiceType)) { + taxRateDetail = "0.000"; + } + log.info("明细-发票税率为:{}", taxRateDetail); + snDetailMap.put("taxRate", taxRateDetail); + } + } + + log.info("明细-tax={}", detail.get("se")); + log.info("明细-commodityCode={}", detail.get("ssflbm")); + snDetailMap.put("currentDateEnd", detail.getString("txrqz")); + snDetailMap.put("currentDateStart", detail.getString("txrqq")); + snDetailMap.put("licensePlateNum", detail.getString("cph")); + snDetailMap.put("type", detail.getString("lx")); + + returnDetailList.add(snDetailMap); + } + + checkInvoice.put("invoiceLineList", returnDetailList); + } + /** * 查验发票 */ diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtCustomsController.java b/dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtCustomsController.java index 009c6ffd..452f82da 100644 --- a/dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtCustomsController.java +++ b/dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtCustomsController.java @@ -117,6 +117,30 @@ public class ExtCustomsController extends AbstractController { if("99".equals(pramsMap.get("rzhYesorno"))){ pramsMap.put("rzhYesorno", null); } + + if(pramsMap.get("imageNumber") != null){ + pramsMap.put("imageId",pramsMap.get("imageNumber")); + } + + if(pramsMap.get("snVoucherNumber") != null){ + pramsMap.put("snVoucherNumber",pramsMap.get("snVoucherNumber")); + } + + if(pramsMap.get("accountPeriod") != null){ + pramsMap.put("accountPeriod",pramsMap.get("accountPeriod")); + } + + if (pramsMap.get("postingTimeStart") != null && !"".equals(pramsMap.get("postingTimeStart"))) { + pramsMap.put("postingTimeStart", + DateUtils.getMorning(DateUtils.strToDate(pramsMap.get("postingTimeStart").toString()))); + } + if (pramsMap.get("postingTimeEnd") != null && !"".equals(pramsMap.get("postingTimeEnd"))) { + pramsMap.put("postingTimeEnd", + DateUtils.getNight(DateUtils.strToDate(pramsMap.get("postingTimeEnd").toString()))); + } + + log.info("请求列表的参数为:{}",pramsMap); + try { return ResponseEntity.ok(Objects .requireNonNull(R.ok().put("data", customsService.selectByPramsMap(pramsMap, curr, size)))); diff --git a/dxhy-extend/src/main/resources/mapper/CustomsMapper.xml b/dxhy-extend/src/main/resources/mapper/CustomsMapper.xml index 04fb6275..24ca22fa 100644 --- a/dxhy-extend/src/main/resources/mapper/CustomsMapper.xml +++ b/dxhy-extend/src/main/resources/mapper/CustomsMapper.xml @@ -137,12 +137,12 @@ and t.sn_voucher_number = #{snVoucherNumber} - - and t.posting_time = #{postingTime} - and t.image_id = #{imageId} + + and t.posting_time between #{postingTimeStart} and #{postingTimeEnd} + and t.account_period = #{accountPeriod} diff --git a/dxhy-extend/src/main/resources/mapper/ExtBbycfpcxMapper.xml b/dxhy-extend/src/main/resources/mapper/ExtBbycfpcxMapper.xml index 8e5b5268..6880a98d 100644 --- a/dxhy-extend/src/main/resources/mapper/ExtBbycfpcxMapper.xml +++ b/dxhy-extend/src/main/resources/mapper/ExtBbycfpcxMapper.xml @@ -62,18 +62,19 @@ and t.qs_status = #{qszt} - + and t.rzh_yesorno = #{rzzt} + + and (t.rzh_yesorno = '2' OR t.rzh_yesorno = '3') + and t.xf_name like CONCAT(#{xfmc},'%') - + and t.invoice_no = #{invoiceNo} - + and t.dept_id = #{businessCode}