From ec424c94b0cceed82f3b3e125706eff315cf1c41 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 06 九月 2021 15:00:50 +0800
Subject: [PATCH] 优化代码
---
service-front/src/main/java/com/java110/front/controller/app/NotifyDemo.java | 6 +
service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovAdapt.java | 105 ++++++++++++++++++++++++++
service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovReturnAdapt.java | 79 +++++++++++++++++++
service-front/src/main/java/com/java110/front/controller/app/PaymentController.java | 2
4 files changed, 190 insertions(+), 2 deletions(-)
diff --git a/service-front/src/main/java/com/java110/front/controller/app/NotifyDemo.java b/service-front/src/main/java/com/java110/front/controller/app/NotifyDemo.java
index d4c6458..2e4081e 100644
--- a/service-front/src/main/java/com/java110/front/controller/app/NotifyDemo.java
+++ b/service-front/src/main/java/com/java110/front/controller/app/NotifyDemo.java
@@ -29,7 +29,7 @@
public static void main(String[] args) throws Exception {
/*鎺ユ敹鍙傛暟*/
- String p = "{msgType=wx.notify, payTime=2021-09-03 11:25:20, buyerCashPayAmt=10, connectSys=UNIONPAY, sign=21B89B7F9EB6837430A8B30E1DF779D7, merName=闈掓捣寰峰潳鐢靛姏鏈夐檺鍏徃, mid=898630149000110, invoiceAmount=10, settleDate=2021-09-03, billFunds=鐜伴噾:10, buyerId=otdJ_uCsgFQi-XigMpadM9gB4h0w, mchntUuid=2d9081bd76d235d20176da1bf4f62bc9, tid=CV5EW7IM, instMid=YUEDANDEFAULT, receiptAmount=10, couponAmount=0, targetOrderId=4200001202202109033453643518, signType=MD5, billFundsDesc=鐜伴噾鏀粯0.10鍏冦��, subBuyerId=oBFo-5-xs50SKaC5hjYf2Ux_Ww2g, orderDesc=闈掓捣寰峰潳鐢靛姏鏈夐檺鍏徃, seqId=23336168921N, merOrderId=1017102021090390760012, targetSys=WXPay, bankInfo=OTHERS, CJ=iIAF, totalAmount=10, wId=hFXywDBfLkpKik7ZLPlAsRUQ4qORS1n8, createTime=2021-09-03 11:25:14, buyerPayAmount=10, notifyId=33e8d307-35ab-4a5a-9551-70a404a45cc6, subInst=103800, status=TRADE_SUCCESS}";
+ String p = "{msgType=wx.notify, payTime=2021-09-06 14:45:10, buyerCashPayAmt=10, connectSys=UNIONPAY, sign=93A2A241A84F822B37E13895A1D6FD8CB4CCABEA095A60EFC9646EC4594F5114, merName=闈掓捣寰峰潳鐢靛姏鏈夐檺鍏徃, mid=898630149000110, invoiceAmount=10, settleDate=2021-09-06, billFunds=鐜伴噾:10, buyerId=otdJ_uCsgFQi-XigMpadM9gB4h0w, mchntUuid=2d9081bd76d235d20176da1bf4f62bc9, tid=CV5EW7IM, instMid=YUEDANDEFAULT, receiptAmount=10, couponAmount=0, targetOrderId=4200001180202109067432700837, signType=SHA256, billFundsDesc=鐜伴噾鏀粯0.10鍏冦��, subBuyerId=oBFo-5-xs50SKaC5hjYf2Ux_Ww2g, orderDesc=闈掓捣寰峰潳鐢靛姏鏈夐檺鍏徃, seqId=23389562168N, merOrderId=11WP102021090602190026, targetSys=WXPay, bankInfo=OTHERS, Ru=NcFv, totalAmount=10, wId=hFXywDBfLkpKik7ZLPlAsRUQ4qORS1n8, createTime=2021-09-06 14:45:03, buyerPayAmount=10, notifyId=d16d35c6-a53d-4ee4-89d1-f08fd8c7b462, subInst=103800, status=TRADE_SUCCESS}";
Map<String, String> params =mapStringToMap(p);
System.out.println("params:" + params);
String sign = params.get("sign");
@@ -81,7 +81,7 @@
String preStr = buildSignString(params); // 鎶婃暟缁勬墍鏈夊厓绱狅紝鎸夌収鈥滃弬鏁�=鍙傛暟鍊尖�濈殑妯″紡鐢ㄢ��&鈥濆瓧绗︽嫾鎺ユ垚瀛楃涓�
String text = preStr + md5Key;
System.out.println("寰呯鍚嶅瓧绗︿覆锛�" + text);
- return DigestUtils.md5Hex(getContentBytes(text)).toUpperCase();
+ return DigestUtils.sha256Hex(getContentBytes(text)).toUpperCase();
}
// 鏋勫缓绛惧悕瀛楃涓�
@@ -98,6 +98,8 @@
for (String key : params.keySet()) {
if ("sign".equals(key))
continue;
+ if ("wId".equals(key))
+ continue;
if (StringUtils.isEmpty(params.get(key)))
continue;
keys.add(key);
diff --git a/service-front/src/main/java/com/java110/front/controller/app/PaymentController.java b/service-front/src/main/java/com/java110/front/controller/app/PaymentController.java
index 33b4b57..6404e79 100755
--- a/service-front/src/main/java/com/java110/front/controller/app/PaymentController.java
+++ b/service-front/src/main/java/com/java110/front/controller/app/PaymentController.java
@@ -331,6 +331,8 @@
for (String key : params.keySet()) {
if ("sign".equals(key))
continue;
+ if ("wId".equals(key))
+ continue;
if (StringUtils.isEmpty(params.get(key)))
continue;
keys.add(key);
diff --git a/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovAdapt.java b/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovAdapt.java
new file mode 100644
index 0000000..8fb7cf1
--- /dev/null
+++ b/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovAdapt.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2017-2020 鍚村鏂� and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.adapt.hcGov.inoutRecord;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.community.CommunityAttrDto;
+import com.java110.dto.community.CommunityDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcGov.HcGovConstant;
+import com.java110.job.adapt.hcGov.asyn.BaseHcGovSendAsyn;
+import com.java110.po.community.CommunityLocationPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 鏂板浣嶇疆鍚屾HC鏀垮姟鎺ュ彛
+ * <p>
+ * 鎺ュ彛鍗忚鍦板潃锛� https://gitee.com/java110/microCommunityInformation/tree/master/info-doc#1%E6%A5%BC%E6%A0%8B%E4%B8%8A%E4%BC%A0
+ *
+ * @desc add by 鍚村鏂� 16:20
+ */
+@Component(value = "addLocationToHcGovAdapt")
+public class AddInoutRecordToHcGovAdapt extends DatabusAdaptImpl {
+
+ @Autowired
+ private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+
+ @Autowired
+ private BaseHcGovSendAsyn baseHcGovSendAsynImpl;
+
+
+ /**
+ * @param business 褰撳墠澶勭悊涓氬姟
+ * @param businesses 鎵�鏈変笟鍔′俊鎭�
+ */
+ @Override
+ public void execute(Business business, List<Business> businesses) {
+ JSONObject data = business.getData();
+ if (data.containsKey(CommunityLocationPo.class.getSimpleName())) {
+ Object bObj = data.get(CommunityLocationPo.class.getSimpleName());
+ JSONArray businessCommunityLocations = null;
+ if (bObj instanceof JSONObject) {
+ businessCommunityLocations = new JSONArray();
+ businessCommunityLocations.add(bObj);
+ } else if (bObj instanceof List) {
+ businessCommunityLocations = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+ } else {
+ businessCommunityLocations = (JSONArray) bObj;
+ }
+ //JSONObject businessCommunityLocation = data.getJSONObject("businessCommunityLocation");
+ for (int bCommunityLocationIndex = 0; bCommunityLocationIndex < businessCommunityLocations.size(); bCommunityLocationIndex++) {
+ JSONObject businessCommunityLocation = businessCommunityLocations.getJSONObject(bCommunityLocationIndex);
+ doAddCommunityLocation(business, businessCommunityLocation);
+
+ }
+ }
+ }
+
+ private void doAddCommunityLocation(Business business, JSONObject businessCommunityLocation) {
+
+ CommunityLocationPo communityLocationPo = BeanConvertUtil.covertBean(businessCommunityLocation, CommunityLocationPo.class);
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setCommunityId(communityLocationPo.getCommunityId());
+ List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+
+ Assert.listNotNull(communityDtos, "鏈寘鍚皬鍖轰俊鎭�");
+ CommunityDto tmpCommunityDto = communityDtos.get(0);
+ String extCommunityId = "";
+ String communityId = tmpCommunityDto.getCommunityId();
+ String communityLocationId = communityLocationPo.getLocationId();
+
+ for (CommunityAttrDto communityAttrDto : tmpCommunityDto.getCommunityAttrDtos()) {
+ if (HcGovConstant.EXT_COMMUNITY_ID.equals(communityAttrDto.getSpecCd())) {
+ extCommunityId = communityAttrDto.getValue();
+ }
+ }
+
+ JSONObject body = new JSONObject();
+ body.put("name", communityLocationPo.getLocationName());
+
+ JSONObject kafkaData = baseHcGovSendAsynImpl.createHeadersOrBody(body, extCommunityId, HcGovConstant.ADD_LOCATION_ACTION, HcGovConstant.COMMUNITY_SECURE);
+ baseHcGovSendAsynImpl.sendKafka(HcGovConstant.GOV_TOPIC, kafkaData, communityId, communityLocationId, HcGovConstant.COMMUNITY_SECURE);
+ }
+
+}
diff --git a/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovReturnAdapt.java b/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovReturnAdapt.java
new file mode 100644
index 0000000..94460c2
--- /dev/null
+++ b/service-job/src/main/java/com/java110/job/adapt/hcGov/inoutRecord/AddInoutRecordToHcGovReturnAdapt.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2017-2020 鍚村鏂� and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.adapt.hcGov.inoutRecord;
+
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.communityLocationAttr.CommunityLocationAttrDto;
+import com.java110.dto.hcGovTranslate.HcGovTranslateDto;
+import com.java110.dto.reportData.ReportDataDto;
+import com.java110.intf.common.IHcGovTranslateInnerServiceSMO;
+import com.java110.intf.community.ICommunityLocationAttrInnerServiceSMO;
+import com.java110.job.adapt.hcGov.HcGovConstant;
+import com.java110.job.adapt.hcGov.IReportReturnDataAdapt;
+import com.java110.po.communityLocationAttr.CommunityLocationAttrPo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 鏂板妤兼爧鍚屾HC鏀垮姟鎺ュ彛 杩斿洖
+ * <p>
+ * 鎺ュ彛鍗忚鍦板潃锛� https://gitee.com/java110/microCommunityInformation/tree/master/info-doc#1%E6%A5%BC%E6%A0%8B%E4%B8%8A%E4%BC%A0
+ *
+ * @desc add by 鍚村鏂� 16:20
+ */
+@Component(value = "ADD_LOCATION_RETURN")
+public class AddInoutRecordToHcGovReturnAdapt implements IReportReturnDataAdapt {
+
+ @Autowired
+ private ICommunityLocationAttrInnerServiceSMO communityLocationAttrInnerServiceSMOImpl;
+ @Autowired
+ private IHcGovTranslateInnerServiceSMO hcGovTranslateInnerServiceSMOImpl;
+
+ @Override
+ public void reportReturn(ReportDataDto reportDataDto, String extCommunityId) {
+
+ HcGovTranslateDto hcGovTranslateDto = new HcGovTranslateDto();
+ hcGovTranslateDto.setTranId(reportDataDto.getReportDataHeaderDto().getTranId());
+ hcGovTranslateDto.setServiceCode(reportDataDto.getReportDataHeaderDto().getServiceCode());
+ List<HcGovTranslateDto> hcGovTranslateDtos = hcGovTranslateInnerServiceSMOImpl.queryHcGovTranslates(hcGovTranslateDto);
+ if (hcGovTranslateDtos == null || hcGovTranslateDtos.size() < 1) {
+ throw new IllegalArgumentException("鏌ヨ鎺ㄩ�佹姤鏂囧け璐ャ�備笉鏄悓涓�璁㈠崟淇℃伅");
+ }
+
+ CommunityLocationAttrDto communityLocationAttrDto = new CommunityLocationAttrDto();
+ communityLocationAttrDto.setLocationId(hcGovTranslateDtos.get(0).getObjId());
+ communityLocationAttrDto.setCommunityId(hcGovTranslateDtos.get(0).getCommunityId());
+ communityLocationAttrDto.setSpecCd( HcGovConstant.EXT_COMMUNITY_ID);
+ List<CommunityLocationAttrDto> communityLocationAttrDtos = communityLocationAttrInnerServiceSMOImpl.queryCommunityLocationAttrs(communityLocationAttrDto);
+
+ CommunityLocationAttrPo communityLocationAttrPo = new CommunityLocationAttrPo();
+ communityLocationAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_locationId));
+ communityLocationAttrPo.setLocationId(communityLocationAttrDto.getLocationId());
+ communityLocationAttrPo.setCommunityId(communityLocationAttrDto.getCommunityId());
+ communityLocationAttrPo.setSpecCd(communityLocationAttrDto.getSpecCd());
+ communityLocationAttrPo.setValue(reportDataDto.getReportDataBodyDto().getString("extLocationId"));
+ if (communityLocationAttrDtos == null || communityLocationAttrDtos.size() < 1) {
+ int flag = communityLocationAttrInnerServiceSMOImpl.saveCommunityLocationAttr(communityLocationAttrPo);
+ if (flag < 1) {
+ throw new IllegalArgumentException("淇濆瓨妤兼爧灞炴�уけ璐�");
+ }
+ }
+
+
+ }
+}
--
Gitblit v1.8.0