报表名称修改,就餐对象管理增加银行卡字段,增加风控功能
diff --git a/config/application-devel-pg.properties b/config/application-devel-pg.properties
index 4f5b86c..cb84f01 100644
--- a/config/application-devel-pg.properties
+++ b/config/application-devel-pg.properties
@@ -34,4 +34,6 @@
cron.offlinedtl= 0 0/5 * * * ?
payapi.logintime= 0 0/5 * * * ?
-restaurant.check_discount_expire.cron=-
\ No newline at end of file
+restaurant.check_discount_expire.cron=-
+
+auditsys.url=http://172.28.43.20:8082/collect/device/
\ No newline at end of file
diff --git a/sql/restarant_create_table.sql b/sql/restarant_create_table.sql
index 60cdc07..a93bdd5 100644
--- a/sql/restarant_create_table.sql
+++ b/sql/restarant_create_table.sql
@@ -1185,6 +1185,14 @@
ALTER TABLE tb_whitelist_devbind ADD CONSTRAINT whitelistid_devbind_uk UNIQUE (deviceid, whitelistid);
+CREATE TABLE "tb_oper_query_limit" (
+ "opercode" varchar(32) COLLATE "pg_catalog"."default" NOT NULL,
+ "devgroupid" int4 NOT NULL
+)
+;
+
+ALTER TABLE "public"."tb_oper_query_limit" ADD CONSTRAINT "tb_oper_query_limit_pkey" PRIMARY KEY ("opercode");
+
-- ----------------------------
-- Sequence structure for seq_area
-- ----------------------------
diff --git a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
index 650c6a1..b4d73f5 100644
--- a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
@@ -1,5 +1,6 @@
package com.supwisdom.dlpay.api.service.impl;
+import com.google.gson.Gson;
import com.supwisdom.dlpay.api.bean.*;
import com.supwisdom.dlpay.api.service.PosPayService;
import com.supwisdom.dlpay.api.util.ErrorCode;
@@ -21,6 +22,7 @@
import com.supwisdom.dlpay.restaurant.domain.*;
import com.supwisdom.dlpay.restaurant.service.*;
import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import com.supwisdom.dlpay.util.HttpConnectionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +30,9 @@
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@Service
@@ -39,6 +43,8 @@
@Autowired
private DeviceService deviceService;
@Autowired
+ private DeviceGroupDao deviceGroupDao;
+ @Autowired
private CardService cardService;
@Autowired
private SystemUtilService systemUtilService;
@@ -129,6 +135,28 @@
if (null != whitelistbind) {
resp.setWhitelistid(whitelistbind.getWhitelistid());
}
+
+ TBusinesspara auditsysurl=businessparaDao.findByParakey("auditsys.url");
+ if(null!=auditsysurl){
+ HttpConnectionUtil util = new HttpConnectionUtil();
+
+ Map<String,String> map=new HashMap<>();
+ TDeviceGroup deviceGroup=deviceGroupDao.getOne(tDevice.getDevgroupid());
+ if(null!=deviceGroup){
+ map.put("areaname",deviceGroup.getGroupname());
+ }else{
+ map.put("areaname","Test");
+ }
+ map.put("status","1");
+ map.put("devicename",tDevice.getDevicename());
+ map.put("devphyid",tDevice.getDevphyid());
+ map.put("source","restaurant");
+ Gson gson=new Gson();
+ String result=util.sendByPostJson(auditsysurl.getParaval()+"/register",gson.toJson(map));
+ logger.info(result);
+ }
+
+
Integer onlineseqno = transDtlService.getMaxSeqnoToday(tDevice.getId(), req.getTermdate());
resp.setCardverno(req.getCardverno());
resp.setOnlineseqno(onlineseqno + 1);
@@ -789,6 +817,19 @@
resp.setWhitelistid(bind.getWhitelistid());
}
+ TBusinesspara auditsysurl=businessparaDao.findByParakey("auditsys.url");
+ if(null!=auditsysurl){
+ HttpConnectionUtil util = new HttpConnectionUtil();
+
+ Map<String,String> map=new HashMap<>();
+ map.put("devphyid",device.getDevphyid());
+ map.put("source","restaurant");
+ Gson gson=new Gson();
+ String result=util.sendByPostJson(auditsysurl.getParaval()+"/beat",gson.toJson(map));
+ logger.info(result);
+ }
+
+
resp.setRetcode(ErrorCode.ERRIF_OK);
resp.setRetmsg("心跳成功");
resp.setSystime(datetime);
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
index b8fbe60..7a1ccf9 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/DeviceGroupDao.java
@@ -9,11 +9,6 @@
public interface DeviceGroupDao extends JpaRepository<TDeviceGroup, Integer> {
-/* @Modifying
- @Transactional
- @Query("delete from TDeviceGroup where devgroupid =:id or pid=:id")
- int deleteByQuery(@Param("id") Integer id);*/
-
int deleteByDevgroupid(Integer Devgroupid);
Integer countByPid(Integer Devgroupid);
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
index 9c2914e..d057192 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
@@ -123,6 +123,7 @@
for(CustomerShowBean bean:list){
bean.setCustname(DataUtil.dataDesensitization(bean.getCustname(),1));
bean.setCardno(DataUtil.dataDesensitization(bean.getCardno(),4));
+ bean.setBankcardno(DataUtil.dataDesensitization(bean.getBankcardno(),6,4));
}
}
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceServiceImpl.java
index 9ba6670..d7d5ff6 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceServiceImpl.java
@@ -1,7 +1,10 @@
package com.supwisdom.dlpay.restaurant.service.impl;
+import com.google.gson.Gson;
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.exception.WebCheckException;
+import com.supwisdom.dlpay.framework.dao.BusinessparaDao;
+import com.supwisdom.dlpay.framework.domain.TBusinesspara;
import com.supwisdom.dlpay.framework.util.DateUtil;
import com.supwisdom.dlpay.restaurant.bean.DeviceSearchBean;
import com.supwisdom.dlpay.restaurant.dao.DeviceDao;
@@ -17,6 +20,7 @@
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.framework.util.StringUtil;
import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import com.supwisdom.dlpay.util.HttpConnectionUtil;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
@@ -36,10 +40,7 @@
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
+import java.util.*;
@Service
public class DeviceServiceImpl implements DeviceService {
@@ -51,6 +52,8 @@
private ShopSettlementDao shopSettlementDao;
@Autowired
private DeviceGroupDao deviceGroupDao;
+ @Autowired
+ private BusinessparaDao businessparaDao;
@PersistenceContext
private EntityManager entityManager;
@@ -215,9 +218,30 @@
if (!temp.isPresent()) {
return false;
}
- TDevice op = temp.get();
- op.setState(state);
- deviceDao.save(op);
+ TDevice device = temp.get();
+ device.setState(state);
+ deviceDao.save(device);
+
+ if(0==state){
+ TBusinesspara auditsysurl=businessparaDao.findByParakey("auditsys.url");
+ if(null!=auditsysurl){
+ HttpConnectionUtil util = new HttpConnectionUtil();
+
+ Map<String,String> map=new HashMap<>();
+ TDeviceGroup deviceGroup=deviceGroupDao.getOne(device.getDevgroupid());
+ if(null!=deviceGroup){
+ map.put("areaname",deviceGroup.getGroupname());
+ }else{
+ map.put("areaname","Test");
+ }
+ map.put("status","2");
+ map.put("devicename",device.getDevicename());
+ map.put("devphyid",device.getDevphyid());
+ map.put("source","restaurant");
+ Gson gson=new Gson();
+ String result=util.sendByPostJson(auditsysurl.getParaval()+"/register",gson.toJson(map));
+ }
+ }
return true;
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/util/DataUtil.java b/src/main/java/com/supwisdom/dlpay/restaurant/util/DataUtil.java
index 30d079c..5b585f7 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/util/DataUtil.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/util/DataUtil.java
@@ -11,8 +11,28 @@
String preStr = data.substring(0, length);
StringBuilder result = new StringBuilder(preStr);
for (int i = 0; i < originLength - preStr.length(); i++) {
- result.append("X");
+ result.append("*");
}
return result.toString();
}
+
+ public static String dataDesensitization(String data,int startlength,int endlength) {
+ if (StringUtil.isEmpty(data)) {
+ return "";
+ }
+ int originLength = data.length();
+ String preStr = data.substring(0, startlength);
+ StringBuilder result = new StringBuilder(preStr);
+ for (int i = 0; i < originLength - startlength-endlength; i++) {
+ result.append("*");
+ }
+ String endStr=data.substring(data.length()-endlength);
+ return result.toString()+endStr;
+ }
+
+ public static void main(String[] args) {
+ String i="61594512365898452369";
+ System.out.println(dataDesensitization(i,6,4));
+
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/util/HttpConnectionUtil.java b/src/main/java/com/supwisdom/dlpay/util/HttpConnectionUtil.java
new file mode 100644
index 0000000..ee5780a
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/util/HttpConnectionUtil.java
@@ -0,0 +1,643 @@
+package com.supwisdom.dlpay.util;
+
+import com.google.gson.Gson;
+import com.supwisdom.dlpay.framework.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.*;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Http工具类
+ *
+ * @version 1.0
+ * @author LIXD
+ */
+public class HttpConnectionUtil {
+
+ /**
+ * Logger for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger(com.supwisdom.dlpay.util.HttpConnectionUtil.class);
+
+ /**
+ * GET方式连接
+ */
+ public static final String METHOD_GET = "GET";
+ /**
+ * POST方式连接
+ */
+ public static final String METHOD_POST = "POST";
+
+ /**
+ * 字符集
+ */
+ private String charset = "UTF-8";
+
+ /**
+ * 待发送请求参数
+ */
+ private Map<String, String> webParams = null;
+
+ /**
+ * 超时时间(毫秒)
+ */
+ private int timeout = 10000;
+
+ public String sendByPost(String targetUrl, Map<String, String> webParams) {
+ if (null == targetUrl) {
+ return null;
+ }
+ URL url = null;
+ try {
+ String requestParams = getRequestParam(webParams);
+ if (null != requestParams) {
+ targetUrl += "?" + requestParams;
+ }
+ if (!targetUrl.startsWith("http")) {
+ targetUrl = "http://" + targetUrl;
+ }
+ url = new URL(targetUrl);
+ log.info(">> post {}",targetUrl);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return null;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ return null;
+ }
+ if (targetUrl.startsWith("https")) {
+ // https
+ HttpsURLConnection connection = null;
+ try {
+ SSLContext sslcontext = SSLContext.getInstance("TLS");
+ sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ connection = (HttpsURLConnection) url.openConnection();
+ connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setRequestProperty("accept", "*/*");
+ connection.connect();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("https get response code is {}", code);
+ return null;
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ connection.getInputStream()));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ }
+ } else {
+ // http
+ HttpURLConnection connection = null;
+ try {
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.connect();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("http get response code is {}", code);
+ return null;
+ }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ connection.getInputStream()));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ return response.toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ }
+ }
+ }
+
+ /**
+ * 通过post发送http请求(form)
+ */
+ public String sendByPostForm(String targetUrl, Map<String, String> webParams) {
+ URL url = null;
+ OutputStream stream = null;
+ BufferedReader reader = null;
+ String requestParams = null;
+ try {
+ requestParams = getRequestParam(webParams);
+ if (null == requestParams) {
+ requestParams = "";
+ }
+ if (!targetUrl.startsWith("http")) {
+ targetUrl = "http://" + targetUrl;
+ }
+ url = new URL(targetUrl);
+ log.info("post {}",targetUrl);
+ log.info("post form data {}",requestParams);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ if (targetUrl.startsWith("https")) {
+ // https
+ HttpsURLConnection connection = null;
+ try {
+ SSLContext sslcontext = SSLContext.getInstance("TLS");
+ sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ connection = (HttpsURLConnection) url.openConnection();
+ connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(requestParams.getBytes(charset).length));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(requestParams.toString().getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("https post response code is {}", code);
+ return null;
+ }
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ log.info("resp data : {}",response.toString());
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ } else {
+ HttpURLConnection connection = null;
+ try {
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length",String.valueOf(requestParams.getBytes(charset).length));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(requestParams.toString().getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("http post response code is {}", code);
+ return null;
+ }
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ log.info("resp data : {}",response.toString());
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * 通过post发送Json数据
+ */
+ public String sendByPostJson(String targetUrl, String jsonString) {
+ URL url = null;
+ OutputStream stream = null;
+ BufferedReader reader = null;
+ try {
+ if (!targetUrl.startsWith("http")) {
+ targetUrl = "http://" + targetUrl;
+ }
+ url = new URL(targetUrl);
+ log.info("post {}",targetUrl);
+ log.info("post json data {}",jsonString);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ if (targetUrl.startsWith("https")) {
+ // https
+ HttpsURLConnection connection = null;
+ try {
+ SSLContext sslcontext = SSLContext.getInstance("TLS");
+ sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ connection = (HttpsURLConnection) url.openConnection();
+ connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json");
+ connection.setRequestProperty("Content-Length", String.valueOf(jsonString.getBytes(charset).length));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(jsonString.getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("https post response code is {}", code);
+ return null;
+ }
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ } else {
+ HttpURLConnection connection = null;
+ try {
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json");
+ connection.setRequestProperty("Content-Length", String.valueOf(jsonString.getBytes(charset).length));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(jsonString.getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("http post response code is {}", code);
+ return null;
+ }
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * 通过post发送http请求
+ */
+ public String sendByPost2(String targetUrl, Map<String, String> webParams) {
+ URL url = null;
+ OutputStream stream = null;
+ BufferedReader reader = null;
+ String requestParams = null;
+ try {
+ requestParams = getRequestParam(webParams);
+ if (null == requestParams) {
+ requestParams = "";
+ }
+ if (!targetUrl.startsWith("http")) {
+ targetUrl = "http://" + targetUrl;
+ }
+ url = new URL(targetUrl);
+ log.info("post {}",targetUrl);
+ log.info("post data {}",requestParams);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ if (targetUrl.startsWith("https")) {
+ // https
+ HttpsURLConnection connection = null;
+ try {
+ SSLContext sslcontext = SSLContext.getInstance("TLS");
+ sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ connection = (HttpsURLConnection) url.openConnection();
+ connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ //connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(requestParams.length()));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(requestParams.toString().getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("https post response code is {}", code);
+ return null;
+ }
+ reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+ String line;
+ StringBuffer response = new StringBuffer(128);
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ return response.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ } else {
+ HttpURLConnection connection = null;
+ try {
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod(METHOD_POST);
+ connection.setReadTimeout(timeout);
+ connection.setConnectTimeout(timeout);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+// connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(requestParams.length()));
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ stream = new DataOutputStream(connection.getOutputStream());
+ stream.write(requestParams.toString().getBytes(charset));
+ stream.flush();
+ int code = connection.getResponseCode();
+ if (code != 200) {
+ log.warn("http post response code is {}", code);
+ return null;
+ }
+// reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+// String line;
+// StringBuffer response = new StringBuffer(128);
+// while ((line = reader.readLine()) != null) {
+// response.append(line);
+// }
+ InputStream inStream = connection.getInputStream();
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int len = 0;
+ while ((len = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, len);
+ }
+ byte[] data = outStream.toByteArray();
+ outStream.close();
+ inStream.close();
+ return new String(data,charset);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != connection) {
+ connection.disconnect();
+ }
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 获取请求参数
+ *
+ * @param
+ * webParams<key,value>
+ * @return key1=value1&key2=value2...
+ * @throws UnsupportedEncodingException
+ */
+ public String getRequestParam(Map<String, String> webParams) throws UnsupportedEncodingException {
+ StringBuffer requestParam = new StringBuffer(128);
+ if (null != webParams && webParams.size() > 0) {
+ Iterator<String> its = webParams.keySet().iterator();
+ while (its.hasNext()) {
+ String key = its.next();
+ if(!StringUtil.isEmpty(webParams.get(key))){
+ requestParam.append("&").append(key).append("=")
+ .append(URLEncoder.encode(webParams.get(key), charset));
+ }
+ }
+ return requestParam.substring(1).toString();
+ }
+ return null;
+ }
+
+ /**
+ * 获取请求参数
+ *
+ * @param
+ * webParams<key,value>
+ * @return key1=value1&key2=value2...
+ * @throws UnsupportedEncodingException
+ */
+ public String getRequestParamNoEncode(Map<String, String> webParams) throws UnsupportedEncodingException {
+ StringBuffer requestParam = new StringBuffer(128);
+ if (null != webParams && webParams.size() > 0) {
+ Iterator<String> its = webParams.keySet().iterator();
+ while (its.hasNext()) {
+ String key = its.next();
+ requestParam.append("&").append(key).append("=")
+ .append(webParams.get(key));
+ }
+ return requestParam.substring(1).toString();
+ }
+ return null;
+ }
+
+ public Map<String, String> getWebParams() {
+ return webParams;
+ }
+
+ public void setWebParams(Map<String, String> webParams) {
+ this.webParams = webParams;
+ }
+
+ public int getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ public String getCharset() {
+ return charset;
+ }
+
+ public void setCharset(String charset) {
+ this.charset = charset;
+ }
+
+
+
+/* public static void main(String[] args) {
+ String url="172.28.43.20:8082/collect/device/register";
+
+ Map<String,String> map=new HashMap<>();
+ map.put("areaname","Test");
+ map.put("status","1");
+ map.put("devicename","Test2");
+ map.put("devphyid","12345687");
+ map.put("source","restaurant");
+ Gson gson=new Gson();
+ System.out.println();
+
+ String i=sendByPostJson(url,gson.toJson(map));
+
+
+ }*/
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/supwisdom/dlpay/util/TrustAllX509TrustManager.java b/src/main/java/com/supwisdom/dlpay/util/TrustAllX509TrustManager.java
new file mode 100644
index 0000000..45544df
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/util/TrustAllX509TrustManager.java
@@ -0,0 +1,52 @@
+package com.supwisdom.dlpay.util;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * 授信类-默认实现
+ *
+ * @version 1.0
+ * @author LIXD
+ */
+public class TrustAllX509TrustManager implements X509TrustManager {
+
+ private X509TrustManager standardTrustManager = null;
+
+ public TrustAllX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException,
+ KeyStoreException {
+ super();
+ TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory
+ .getDefaultAlgorithm());
+ factory.init(keystore);
+ TrustManager[] trustmanagers = factory.getTrustManagers();
+ if (trustmanagers.length == 0) {
+ throw new NoSuchAlgorithmException("no trust manager found");
+ }
+ this.standardTrustManager = (X509TrustManager) trustmanagers[0];
+ }
+
+ public void checkClientTrusted(X509Certificate[] certificates, String authType)
+ throws CertificateException {
+ standardTrustManager.checkClientTrusted(certificates, authType);
+ }
+
+ public void checkServerTrusted(X509Certificate[] certificates, String authType)
+ throws CertificateException {
+ if ((certificates != null) && (certificates.length == 1)) {
+ certificates[0].checkValidity();
+ } else {
+ standardTrustManager.checkServerTrusted(certificates, authType);
+ }
+ }
+
+ public X509Certificate[] getAcceptedIssuers() {
+ return this.standardTrustManager.getAcceptedIssuers();
+ }
+}
diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql
index 204f901..e99ea7e 100644
--- a/src/main/resources/data.sql
+++ b/src/main/resources/data.sql
@@ -126,6 +126,9 @@
INSERT INTO "tb_function" VALUES (40, NULL, 1, NULL, '', '/dept/index', '部门管理', 6, 22);
INSERT INTO "tb_function" VALUES (41, NULL, 1, NULL, '', '/custtypereport/index', '人员类别消费报表', 4, 35);
INSERT INTO "tb_function" VALUES (42, NULL, 1, NULL, '', '/transcountreport/index', '消费人次报表', NULL, 36);
+INSERT INTO "tb_function" VALUES (44, NULL, 1, NULL, '', '/transdtl/indexview', '食堂流水表', NULL, 28);
+INSERT INTO "tb_function" VALUES (43, NULL, 1, NULL, '', '/termreport/index', '终端消费报表', 6, 36);
+INSERT INTO "tb_function" VALUES (45, NULL, 1, NULL, '', '/custreport/index', '个人流水报表', NULL, 36);
INSERT INTO "tb_mealtype" (mealtype,endtime,lastsaved,mealname) VALUES ('dinner', '235959', '20190709102922', '晚餐');
@@ -592,6 +595,9 @@
INSERT INTO "tb_role_function" VALUES ('2c9b808672e528ec01730415db811dec', 36, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
INSERT INTO "tb_role_function" VALUES ('2c9b808672e528ec01730415db811ded', 41, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
INSERT INTO "tb_role_function" VALUES ('2c9b808672e528ec01730415db811df0', 37, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
+INSERT INTO "tb_role_function" VALUES ('297e372374d25ed30174d262cdcc0090', 45, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
+INSERT INTO "tb_role_function" VALUES ('297e372374d25ed30174d262cdc9006b', 44, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
+INSERT INTO "tb_role_function" VALUES ('297e372374d25ed30174d262cdcc008f', 43, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
diff --git a/src/main/resources/templates/restaurant/customer/index.html b/src/main/resources/templates/restaurant/customer/index.html
index f896fcf..0282b9c 100644
--- a/src/main/resources/templates/restaurant/customer/index.html
+++ b/src/main/resources/templates/restaurant/customer/index.html
@@ -78,6 +78,8 @@
{field: 'custname', sort: true, title: '客户姓名'},
{field: 'cardno', sort: true, title: '市名卡号'},
{field: 'deptname', sort: true, title: '部门'},
+ {field: 'bankcardno', title: '银行卡号',width:160},
+
{field: 'custtypename', title: '客户类别'},
{
field: 'discnt', title: '有无餐补', align: 'center', width: 120, sort: true, templet: function (d) {
diff --git a/src/main/resources/templates/restaurant/custreport/index.html b/src/main/resources/templates/restaurant/custreport/index.html
index 87e4681..810f47e 100644
--- a/src/main/resources/templates/restaurant/custreport/index.html
+++ b/src/main/resources/templates/restaurant/custreport/index.html
@@ -207,7 +207,7 @@
// 转换完成,创建一个a标签用于下载
var aElem = document.createElement('a');
aElem.href = window.URL.createObjectURL(blob);
- aElem.download = "客户类别消费报表.xls";
+ aElem.download = "个人流水报表.xls";
aElem.onload = function (e) {
window.URL.revokeObjectURL(aElem.href);
};
diff --git a/src/main/resources/templates/restaurant/termreport/index.html b/src/main/resources/templates/restaurant/termreport/index.html
index 6a0c31b..0bc3d75 100644
--- a/src/main/resources/templates/restaurant/termreport/index.html
+++ b/src/main/resources/templates/restaurant/termreport/index.html
@@ -203,7 +203,7 @@
// 转换完成,创建一个a标签用于下载
var aElem = document.createElement('a');
aElem.href = window.URL.createObjectURL(blob);
- aElem.download = "客户类别消费报表.xls";
+ aElem.download = "终端消费报表.xls";
aElem.onload = function (e) {
window.URL.revokeObjectURL(aElem.href);
};