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 f59ee017..85910f17 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 @@ -70,6 +70,11 @@ public class SDNYMainProcessController extends AbstractController { String dbName = "business"; String company = "BIGB"; + // 入参统一在入口处理 +// String userid = getLoginName(); +// String dbName = getUserInfo().getDbName(); +// String company = getUserInfo().getCompany(); + InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode")); String fplxdm = iu.getFplxdm(); @@ -85,7 +90,7 @@ public class SDNYMainProcessController extends AbstractController { pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber")); if (!pramsMap.get("billingDate").isEmpty()) { - String billingDate = pramsMap.get("billingDate").replaceAll("-",""); + String billingDate = pramsMap.get("billingDate").replaceAll("-", ""); iu.setKprq(pramsMap.get("billingDate")); pramsMap.put("invoiceDate", billingDate); pramsMap.put("billingDate", billingDate); @@ -123,8 +128,8 @@ public class SDNYMainProcessController extends AbstractController { //查询底账库是否有对应发票,有则直接返回 TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); - if(checkInvoiceByUuid != null){ - R data = new R(1000,"default success"); + if (checkInvoiceByUuid != null) { + R data = new R(1000, "default success"); String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid); data.put("data", checkInvoice); @@ -140,11 +145,14 @@ public class SDNYMainProcessController extends AbstractController { } if (!checkInvoiceResult.containsKey("code")) { - R data = new R(1000,"default success"); + R data = new R(1000, "default success"); data.put("data", checkInvoiceResult); - if(!checkInvoiceResult.containsKey("cyjg")){ - signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult,userid,"1",dbName); + if (!checkInvoiceResult.containsKey("cyjg")) { + + checkInvoiceResult.put("invoiceNo",checkInvoiceResult.getString("invoiceNumber")); + checkInvoiceResult.put("company",company); + signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); } return ResponseEntity.ok(data); @@ -162,65 +170,78 @@ public class SDNYMainProcessController extends AbstractController { @ResponseBody @SysLog("同步发票信息") public ResponseEntity syncInvoiceInfo(@RequestBody SNRequestObject snRequestObject) { - // 入参统一在入口处理 - String userid = getLoginName(); - String dbName = getUserInfo().getDbName(); - String company = getUserInfo().getCompany(); + log.info("影像系统同步数据:{}",snRequestObject); - List gfshAll = UserInfoUtil.getGfshAll(getUserInfo().getOrg()); - String gfsh = ""; - if (gfshAll.size() > 0) { - gfsh = gfshAll.get(0); - } + String userid = "101833"; + String dbName = "business"; + String company = "BIGB"; +// // 入参统一在入口处理 +// String userid = getLoginName(); +// String dbName = getUserInfo().getDbName(); +// String company = getUserInfo().getCompany(); +// List gfshAll = UserInfoUtil.getGfshAll(getUserInfo().getOrg()); +// String gfsh = ""; +// if (gfshAll.size() > 0) { +// gfsh = gfshAll.get(0); +// } + List invoiceList = snRequestObject.getInvoiceInfoList(); + String result = ""; //入票池 try { - snPushCheckRecordService.pushInvoiceToRecordInvoice2(snRequestObject, gfsh, company); + Integer integer = snPushCheckRecordService.pushInvoiceToRecordInvoice2(snRequestObject); //推送到SAP List invoiceInfoList = snRequestObject.getInvoiceInfoList(); String imageId = snRequestObject.getImageId(); - - for (SNInvoice invoice : invoiceInfoList) { - SNSAPObject object = convertToSapOnject(invoice, imageId); - JSONObject sapObj = (JSONObject) JSONObject.toJSON(object); - - String result = ""; - try { - //将信息推送到影像系统 - result = snPushCheckRecordService.pushCheckResultToSAP(sapObj); - - return ResponseEntity.ok(R.ok().put("data", result)); - } catch (Exception e) { - e.printStackTrace(); - log.error("", e); - return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + String compCode = snRequestObject.getCompCode(); + + if (invoiceInfoList != null && invoiceInfoList.size() > 0) { + for (SNInvoice invoice : invoiceInfoList) { + SNSAPObject object = convertToSapOnject(invoice, imageId,compCode); + String sapObj = JSONObject.toJSONString(object); + log.info("推送山能数据:{}",sapObj); + + JSONObject request = new JSONObject(); + request.put("IS_INPUT",sapObj); + + try { + //将信息推送到影像系统 + result = snPushCheckRecordService.pushCheckResultToSAP(request.toJSONString()); + } catch (Exception e) { + e.printStackTrace(); + log.error("", e); + return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + } } } - return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + + R data = new R(1000, "default success"); + data.put("data", ""); + return ResponseEntity.ok(data); } catch (Exception e) { e.printStackTrace(); } return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); } - private SNSAPObject convertToSapOnject(SNInvoice snInvoice, String imageId) { + private SNSAPObject convertToSapOnject(SNInvoice snInvoice, String imageId,String compCode) { Date date = new Date(); SNSAPObject object = new SNSAPObject(); - object.setSYSID("JS"); + object.setSYSID("FPXT"); object.setIFYWID("FI845"); - object.setBSKEY("a77a8ba6c0dc45cd9e88972fb4750f93"); + object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); object.setSAPKEY(""); - object.setZORG(""); + object.setZORG(compCode); object.setZFILED1(""); object.setZFILED2(""); object.setZFILED3(""); object.setZFILED4(""); - object.setZFILED5("800"); + object.setZFILED5("200"); List sapInvoiceInfos = new ArrayList<>(); SAPInvoiceInfo info = new SAPInvoiceInfo(); info.setZBAZT("0"); @@ -272,6 +293,7 @@ public class SDNYMainProcessController extends AbstractController { sapInvoiceDetail.setZCPH(snInvoiceDetail.getLicensePlateNum()); sapInvoiceDetail.setZCJSJ(""); sapInvoiceDetail.setZCJRQ(""); + sapInvoiceDetail.setFPYXBH(snInvoice.getFileId()); sapInvoiceDetail.setZCFZ(snInvoice.getStationGetOn()); sapInvoiceDetail.setZTXZ(snInvoiceDetail.getCurrentDateEnd()); sapInvoiceDetail.setZTXQ(snInvoiceDetail.getCurrentDateStart()); @@ -290,7 +312,7 @@ public class SDNYMainProcessController extends AbstractController { sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity()); sapInvoiceDetail.setZSM(info.getZSM()); sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel()); - sapInvoiceDetail.setZTID(""); + sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber()); sapInvoiceDetailList.add(sapInvoiceDetail); } @@ -319,8 +341,8 @@ public class SDNYMainProcessController extends AbstractController { info.setZGXR(""); //认证相关 - info.setZRZJG(""); - info.setZRZSSQ(""); + info.setZRZJG("0"); + info.setZRZSSQ("202302"); info.setZRZMS(""); info.setZRZRQ(""); @@ -329,7 +351,7 @@ public class SDNYMainProcessController extends AbstractController { info.setZXFDH(snInvoice.getSalesAddressPhone()); info.setZESCSH(""); - info.setZGSDM("BG90"); + info.setZGSDM(compCode); info.setZGFSH(snInvoice.getPurchaserTaxNo()); info.setZXCRS(snInvoice.getPassengersLimited()); info.setZWSPZ(snInvoice.getPaymentVoucherNo()); @@ -349,10 +371,10 @@ public class SDNYMainProcessController extends AbstractController { info.setZCYRMC(snInvoice.getCarrierName()); info.setZJGDM(snInvoice.getAdministrativeDivisionNo()); info.setZGXSJ(date); - info.setZQM("opentext"); + info.setZQM(""); info.setZPJLY(snInvoice.getSource()); info.setZZWLX(snInvoice.getSeat()); - info.setZTID(""); + info.setZTID("500005000002601689027"); sapInvoiceInfos.add(info); 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 ec35c103..5590bea0 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 @@ -68,6 +68,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Value("${params.api.entCode}") private String entCode; + @Value("${po.userName}") + private String userName; + + @Value("${po.password}") + private String password; + @Resource private InvoiceQueryUtil invoiceQueryUtil; @@ -89,9 +95,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Resource private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; - public String pushCheckResultToSAP(JSONObject result) throws Exception { - log.info("获取请求参数:{} , 请求地址:{}", result, snYxUrl); - String post = HttpUtil.post(snYxUrl, result, 30000); + public String pushCheckResultToSAP(String requestParam) throws Exception { + log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl); + String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password); log.info("获取返回信息:{}", post); if (StringUtils.isNotBlank(post)) { } @@ -167,7 +173,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { return ""; } - public Integer pushInvoiceToRecordInvoice2(SNRequestObject snRequestObject,String taxNo,String company) { + public Integer pushInvoiceToRecordInvoice2(SNRequestObject snRequestObject) { + DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); + int update = 0; List invoiceInfoList = snRequestObject.getInvoiceInfoList(); @@ -183,6 +191,15 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { update = baseTDxRecordInvoiceDao.update(recordInvoice, recordWrapper); } + }else{ + String imageId = snRequestObject.getImageId(); + QueryWrapper recordWrapper = new QueryWrapper<>(); + recordWrapper.eq("image_id", imageId); + BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); + recordInvoice.setImageId(""); + recordInvoice.setCompCode(""); + + update = baseTDxRecordInvoiceDao.update(recordInvoice, recordWrapper); } return update; @@ -319,6 +336,49 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { jsonObject.put("zeroTaxRateSign", invoiceData.get("lslbs")); jsonObject.put("source", ""); jsonObject.put("idcardNo", invoiceData.get("sfzh")); + jsonObject.put("buyerIDNum", invoiceData.get("sfzh")); + jsonObject.put("vehicleType", invoiceData.get("cllx")); + jsonObject.put("factoryModel", invoiceData.get("cpxh")); + jsonObject.put("productPlace", invoiceData.get("cd")); + jsonObject.put("certificate", invoiceData.get("hgzs")); + jsonObject.put("certificateImport", invoiceData.get("jszmsh")); + jsonObject.put("inspectionNum", invoiceData.get("sjdh")); + jsonObject.put("engineNo", invoiceData.get("fdjhm")); + jsonObject.put("vehicleNo", invoiceData.get("clsbh")); + jsonObject.put("engineNo", invoiceData.get("fdjhm")); + jsonObject.put("taxBureauCode", invoiceData.get("zgswjgdm")); + jsonObject.put("taxBureauName", invoiceData.get("zgswjgmc")); + jsonObject.put("taxBureauCode", invoiceData.get("zgswjgdm")); + jsonObject.put("taxRecords", invoiceData.get("wspzhm")); + jsonObject.put("tonnage", invoiceData.get("dw")); + jsonObject.put("limitPeople", invoiceData.get("xcrs")); + jsonObject.put("taxRate", invoiceData.get("sl")); + jsonObject.put("limitPeople", invoiceData.get("sl")); + + jsonObject.put("machineNo", invoiceData.get("jqbh")); + + jsonObject.put("licensePlate", invoiceData.get("jqbh")); + jsonObject.put("machineNo", invoiceData.get("cpzh")); + jsonObject.put("registrationNo", invoiceData.get("djzh")); + jsonObject.put("vehicleIdentificationNo", invoiceData.get("clsbh")); + jsonObject.put("vehicleAdminOffice", invoiceData.get("zrdcgsmc")); + jsonObject.put("buyerUnitOrIndividual", invoiceData.get("mfdwgr")); + jsonObject.put("buyerUnitOrIndividualAddress", invoiceData.get("mfdwgrdz")); + jsonObject.put("buyerPhone", invoiceData.get("mfdh")); + jsonObject.put("sellerUnitOrIndividual", invoiceData.get("smfdwgr")); + jsonObject.put("sellerUnitCodeOrIdNo", invoiceData.get("smfdwdmsfzh")); + jsonObject.put("sellerUnitOrIndividualAddress", invoiceData.get("smfdwgrzz")); + jsonObject.put("sellerPhone", invoiceData.get("smfdh")); + jsonObject.put("businessUnit", invoiceData.get("jypmdw")); + jsonObject.put("businessUnitAddress", invoiceData.get("jypmdwdz")); + jsonObject.put("businessUnitTaxNo", invoiceData.get("jypmdwzsbh")); + jsonObject.put("businessUnitBankAndAccount", invoiceData.get("khyhjzh")); + jsonObject.put("businessUnitPhone", invoiceData.get("jypmdwdh")); + jsonObject.put("lemonMarket", invoiceData.get("escsc")); + jsonObject.put("lemonMarketTaxNo", invoiceData.get("escscsbh")); + jsonObject.put("lemonMarketAddress", invoiceData.get("escscdz")); + jsonObject.put("lemonMarketBankAndAccount", invoiceData.get("escsckhyhzh")); + jsonObject.put("lemonMarketPhone", invoiceData.get("escscdh")); List> returnDetailList = new ArrayList<>(); JSONArray detailList = (JSONArray) invoiceData.get("detailList"); diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceQueryServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceQueryServiceImpl.java index e47c02d9..c17418f4 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceQueryServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceQueryServiceImpl.java @@ -90,7 +90,7 @@ public class InvoiceQueryServiceImpl extends MpBaseServiceImpl getRecordInvoiceDetail(JSONObject queryInvoiceResult) { if (queryInvoiceResult.containsKey("detailList")) { - JSONArray dataArray = queryInvoiceResult.getJSONArray("detailList"); + JSONArray dataArray = queryInvoiceResult.getJSONArray("invoiceLineList"); if (dataArray != null && dataArray.size() > 0) { String invoiceType = queryInvoiceResult.getString("invoiceType"); String invoiceCode = queryInvoiceResult.getString("invoiceCode"); @@ -390,29 +389,29 @@ public class SignSaveInvoiceInfoServiceImpl extends MpBaseServiceImpl paramMap) { + Map requestMap = new HashMap<>(paramMap); + long startTime = System.currentTimeMillis(); + String body = HttpRequest.post(url).form(requestMap).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}以Map调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + public static String doPost(String url, String request) { + long startTime = System.currentTimeMillis(); + String body = HttpRequest.post(url).body(request).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}以字符串调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + public static String doPostWithHeader(String url, String data, Map header) { + long startTime = System.currentTimeMillis(); + String body = HttpRequest.post(url).addHeaders(header).body(data).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}带head调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + public static String doPostFormWithHeader(String url, Map paramMap, Map header) { + Map requestMap = new HashMap<>(paramMap); + long startTime = System.currentTimeMillis(); + String body = HttpRequest.post(url).addHeaders(header).form(requestMap).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}带head和form调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + public static String doGetWithHeader(String url, Map header) { + long startTime = System.currentTimeMillis(); + String body = HttpRequest.get(url).addHeaders(header).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}带head调用get请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + public static String doGet(String url, String request) { + long startTime = System.currentTimeMillis(); + String body = HttpRequest.get(url).body(request).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}以字符串调用get请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + + //请求山能PO + public static String sendPo(String url, String request,String userName,String password) { + long startTime = System.currentTimeMillis(); + HttpRequest httpRequest = new HttpRequest(url); + httpRequest.basicAuth(userName,password); + String body = httpRequest.body(request).timeout(300000).execute().body(); + long endTime = System.currentTimeMillis(); + log.debug("{}以字符串调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime); + return body; + } + +} +