李天标 3 роки тому
батько
коміт
6e45c17574
53 змінених файлів з 5745 додано та 3 видалено
  1. 78 0
      pom.xml
  2. 356 0
      src/main/java/com/szwl/controller/TOrderController.java
  3. 13 0
      src/main/java/com/szwl/feign/SzwlFeign.java
  4. 8 0
      src/main/java/com/szwl/mapper/TOrderMapper.java
  5. 205 1
      src/main/java/com/szwl/mapper/xml/TOrderMapper.xml
  6. 27 0
      src/main/java/com/szwl/model/bean/ChartBean.java
  7. 58 0
      src/main/java/com/szwl/model/bean/ChartColumn.java
  8. 25 0
      src/main/java/com/szwl/model/bean/ChartSerie.java
  9. 48 0
      src/main/java/com/szwl/model/bean/Child.java
  10. 36 0
      src/main/java/com/szwl/model/bean/Childlast.java
  11. 29 0
      src/main/java/com/szwl/model/bean/Children2.java
  12. 29 0
      src/main/java/com/szwl/model/bean/Children3.java
  13. 70 0
      src/main/java/com/szwl/model/bean/CommonParamVo.java
  14. 92 0
      src/main/java/com/szwl/model/bean/EquipmentDTO.java
  15. 191 0
      src/main/java/com/szwl/model/bean/EquipmentVo.java
  16. 100 0
      src/main/java/com/szwl/model/bean/ProductVo.java
  17. 22 0
      src/main/java/com/szwl/model/bean/TAdminDTO.java
  18. 68 0
      src/main/java/com/szwl/model/bean/TEquipmentDTO.java
  19. 20 0
      src/main/java/com/szwl/model/bo/ChartType.java
  20. 321 0
      src/main/java/com/szwl/model/bo/JsonMessage.java
  21. 25 0
      src/main/java/com/szwl/model/bo/ParamNotFoundException.java
  22. 119 0
      src/main/java/com/szwl/model/entity/TAdmin.java
  23. 33 0
      src/main/java/com/szwl/model/entity/TAdminEquipment.java
  24. 75 0
      src/main/java/com/szwl/model/entity/TAlarmRecord.java
  25. 3 0
      src/main/java/com/szwl/model/entity/TCoinOrder.java
  26. 176 0
      src/main/java/com/szwl/model/entity/TEquipment.java
  27. 2 1
      src/main/java/com/szwl/model/entity/TOrder.java
  28. 57 0
      src/main/java/com/szwl/model/query/StatisticsParam.java
  29. 21 0
      src/main/java/com/szwl/model/query/TAdminParam.java
  30. 60 0
      src/main/java/com/szwl/model/query/TCoinOrderParam.java
  31. 68 0
      src/main/java/com/szwl/model/query/TEquipmentParam.java
  32. 65 0
      src/main/java/com/szwl/model/query/TOrderParam.java
  33. 80 0
      src/main/java/com/szwl/model/utils/AESUtil.java
  34. 57 0
      src/main/java/com/szwl/model/utils/AdminUtils.java
  35. 117 0
      src/main/java/com/szwl/model/utils/Base64Util.java
  36. 17 0
      src/main/java/com/szwl/model/utils/CodeUtil.java
  37. 74 0
      src/main/java/com/szwl/model/utils/Constant.java
  38. 266 0
      src/main/java/com/szwl/model/utils/DateUtils.java
  39. 489 0
      src/main/java/com/szwl/model/utils/FgObjectUtil.java
  40. 85 0
      src/main/java/com/szwl/model/utils/HEXUtil.java
  41. 332 0
      src/main/java/com/szwl/model/utils/HttpClientUtils.java
  42. 269 0
      src/main/java/com/szwl/model/utils/JoinpayConstant.java
  43. 293 0
      src/main/java/com/szwl/model/utils/PushUtils.java
  44. 187 0
      src/main/java/com/szwl/model/utils/RSAUtil.java
  45. 14 0
      src/main/java/com/szwl/model/utils/constants/Algorithm.java
  46. 12 0
      src/main/java/com/szwl/model/utils/constants/CommonConst.java
  47. 12 0
      src/main/java/com/szwl/model/utils/exceptions/JPException.java
  48. 3 0
      src/main/java/com/szwl/service/TOrderService.java
  49. 186 0
      src/main/java/com/szwl/service/es/EsTCoinOrderService.java
  50. 344 0
      src/main/java/com/szwl/service/es/EsTEquipmentService.java
  51. 364 0
      src/main/java/com/szwl/service/es/EsTOrderService.java
  52. 36 0
      src/main/java/com/szwl/service/impl/TOrderServiceImpl.java
  53. 8 1
      src/main/resources/bootstrap.yml

+ 78 - 0
pom.xml

@@ -140,6 +140,69 @@
 			<artifactId>hutool-core</artifactId>
 			<version>5.7.16</version>
 		</dependency>
+		<dependency>
+			<groupId>commons-beanutils</groupId>
+			<artifactId>commons-beanutils</artifactId>
+			<version>1.8.3</version>
+		</dependency>
+		<dependency>
+			<groupId>org.hibernate</groupId>
+			<artifactId>hibernate-core</artifactId>
+			<version>3.6.10.Final</version>
+		</dependency>
+		<!-- 引入org.json所需依赖 -->
+		<dependency>
+			<groupId>org.json</groupId>
+			<artifactId>json</artifactId>
+			<version>20200518</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-httpclient</groupId>
+			<artifactId>commons-httpclient</artifactId>
+			<version>3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.16</version>
+		</dependency>
+		<!--杉德支付-->
+		<dependency>
+			<groupId>cn.com.sand</groupId>
+			<artifactId>hmpay-sdk</artifactId>
+			<version>1.1.4</version>
+		</dependency>
+		<!--rabbitmq-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-amqp</artifactId>
+			<version>2.1.3.RELEASE</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-bus-amqp</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.amqp</groupId>
+			<artifactId>spring-rabbit</artifactId>
+			<version>2.3.6</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.amqp</groupId>
+			<artifactId>spring-amqp</artifactId>
+			<version>2.3.6</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.com.crbank.ommo</groupId>
+			<artifactId>EsBaseServer</artifactId>
+			<version>1.2.10</version>
+		</dependency>
+		<!-- 个推 -->
+		<dependency>
+			<groupId>com.gexin.platform</groupId>
+			<artifactId>gexin-rp-sdk-http</artifactId>
+			<version>4.0.1.9</version>
+		</dependency>
 	</dependencies>
 
 	<build>
@@ -164,6 +227,21 @@
 				<enabled>false</enabled>
 			</snapshots>
 		</repository>
+		<!-- 个推 -->
+		<repository>
+			<id>getui-nexus</id>
+			<url>http://mvn.gt.igexin.com/nexus/content/repositories/releases/</url>
+		</repository>
+		<repository>
+			<id>nexus</id>
+			<url>http://www.redouble.store:1888/repository/crbank-host/</url>
+			<releases>
+				<enabled>true</enabled>
+			</releases>
+			<snapshots>
+				<enabled>false</enabled>
+			</snapshots>
+		</repository>
 	</repositories>
 
 

+ 356 - 0
src/main/java/com/szwl/controller/TOrderController.java

@@ -1,16 +1,38 @@
 package com.szwl.controller;
 
 
+import cn.com.crbank.ommo.bean.ResultMessage;
+import cn.com.crbank.ommo.esclient.ElasticsearchRunner;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.szwl.feign.SzwlFeign;
 import com.szwl.feign.bean.TAdminParam;
+import com.szwl.model.bean.ChartColumn;
 import com.szwl.model.bo.R;
 import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.*;
+import com.szwl.model.query.StatisticsParam;
+import com.szwl.model.utils.FgObjectUtil;
+import com.szwl.service.TCoinOrderService;
+import com.szwl.service.TOrderService;
+import com.szwl.service.es.EsTEquipmentService;
+import com.szwl.service.es.EsTOrderService;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * <p>
@@ -20,9 +42,343 @@ import java.util.List;
  * @author wuhs
  * @since 2022-06-14
  */
+@Slf4j
 @RestController
 @RequestMapping("/tOrder")
 public class TOrderController {
+    @Autowired
+    TOrderService orderService;
+    @Autowired
+    EsTOrderService esTOrderService;
+    @Autowired
+    EsTEquipmentService esTEquipmentService;
+    @Autowired
+    TCoinOrderService coinOrderService;
+    @Autowired
+    SzwlFeign szwlFeign;
+    @GetMapping("/pageOrder")
+    public ResponseModel<IPage<?>> pageAd(String adminId,String adminType,String type,String userName,String payType,String productNo,String clientId,String dateType, Date stratDate, Date endDate, long current, long size ) {
+        //判断当前账号状态
+        TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId));
+        //类型
+        //0,线上
+        if(type.equals("0")){
+            LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
+            //adminType="all"时,代表查全部下级  子账户没有这个权限  公司人员默认查所有人
+            if(StringUtils.isNotEmpty(adminType)){
+                if(admin.getIsAdmined().equals("0")&&admin.getType()>1){
+                    if(admin.getType()>1){
+                        if(adminType.equals("all")){
+                            //查找所有下级
+                            List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
+                            query.in(TOrder::getAdminId,admidIdList);
+                        }
+                    }
+                }else{
+                    if(admin.getType()>1){
+                        //登录账户为子账户 不查下级 只查对应机器的订单
+                        TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
+                        if(adminEquipment.getType().equals("0")){
+                            //全部机器
+                            TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
+                            query.eq(TOrder::getAdminId,upAdmin.getId());
+                        }else {
+                            String equipmentIds = adminEquipment.getEquipmentIds();
+                            List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
+                            query.in(TOrder::getClientId,equipmentIdList);
+                        }
+                    }
+                }
 
+            }else {
+                //判断当前账号状态 公司还是商家
+                if(admin.getType()>1){
+                    //商家 判断是否子账户
+                    if(admin.getIsAdmined().equals("0")){
+                        //商家自己
+                        query.eq(TOrder::getAdminId,adminId);
+                    }else {
+                        //商家 子账户
+                        //登录账户为子账户 不查下级 只查对应机器的订单
+                        TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
+                        if(adminEquipment.getType().equals("0")){
+                            //全部机器
+                            TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
+                            query.eq(TOrder::getAdminId,upAdmin.getId());
+                        }else {
+                            String equipmentIds = adminEquipment.getEquipmentIds();
+                            List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
+                            query.in(TOrder::getClientId,equipmentIdList);
+                        }
+                    }
+                }
+            }
+            if(StringUtils.isNotEmpty(userName)){
+                TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdminByUsername(userName));
+                query.eq(TOrder::getAdminId,admin1.getId());
+            }
+            if(StringUtils.isNotEmpty(payType)){
+                query.eq(TOrder::getFrpCode,payType);
+            }
+            if(StringUtils.isNotEmpty(productNo)){
+                query.eq(TOrder::getProductNo,productNo);
+            }
+            if(StringUtils.isNotEmpty(clientId)){
+                TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
+                //判断机器是否属于这个登陆账号
+                if(admin.getType()>1){
+                    //商家
+                    if(equipment.getAdminId().toString().equals(admin.getId().toString())){
+                        query.eq(TOrder::getEquipmentId,equipment.getId());
+                    }
+                }else {
+                    query.eq(TOrder::getEquipmentId,equipment.getId());
+                }
+            }
+            if(StringUtils.isNotEmpty(dateType)){
+                if(dateType.equals("0")){
+                    //创建时间
+                    if(stratDate!=null&&endDate!=null){
+                        query.gt(TOrder::getCreateDate,stratDate);
+                        query.lt(TOrder::getCreateDate,endDate);
+                    }
+                }
+                if(dateType.equals("1")){
+                    //退款时间
+                    if(stratDate!=null&&endDate!=null){
+                        query.gt(TOrder::getRefundDate,stratDate);
+                        query.lt(TOrder::getRefundDate,endDate);
+                    }
+                }
+            }
+            Page<TOrder> page = new Page<>(current, size, true);
+            IPage<TOrder> iPage = orderService.page(page, query);
+            return R.ok(iPage);
+        };
+
+        //1,线下
+        if(type.equals("1")){
+            LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
+            //adminType="all"时,代表查全部下级  子账户没有这个权限  公司人员默认查所有人
+            if(StringUtils.isNotEmpty(adminType)){
+                if(admin.getIsAdmined().equals("0")&&admin.getType()>1){
+                    if(admin.getType()>1){
+                        if(adminType.equals("all")){
+                            //查找所有下级
+                            List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
+                            query.in(TCoinOrder::getAdminId,admidIdList);
+                        }
+                    }
+                }else{
+                    if(admin.getType()>1){
+                        //登录账户为子账户 不查下级 只查对应机器的订单
+                        TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
+                        if(adminEquipment.getType().equals("0")){
+                            //全部机器
+                            TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
+                            query.eq(TCoinOrder::getAdminId,upAdmin.getId());
+                        }else {
+                            String equipmentIds = adminEquipment.getEquipmentIds();
+                            List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
+                            query.in(TCoinOrder::getClientId,equipmentIdList);
+                        }
+                    }
+                }
+
+            }else {
+                //判断当前账号状态 公司还是商家
+                if(admin.getType()>1){
+                    //商家 判断是否子账户
+                    if(admin.getIsAdmined().equals("0")){
+                        //商家自己
+                        query.eq(TCoinOrder::getAdminId,adminId);
+                    }else {
+                        //商家 子账户
+                        //登录账户为子账户 不查下级 只查对应机器的订单
+                        TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getParentId())));
+                        if(adminEquipment.getType().equals("0")){
+                            //全部机器
+                            TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
+                            query.eq(TCoinOrder::getAdminId,upAdmin.getId());
+                        }else {
+                            String equipmentIds = adminEquipment.getEquipmentIds();
+                            List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
+                            query.in(TCoinOrder::getClientId,equipmentIdList);
+                        }
+                    }
+                }
+            }
+            if(StringUtils.isNotEmpty(userName)){
+                TAdmin admin1 = R.getDataIfSuccess(szwlFeign.getAdminByUsername(userName));
+                query.eq(TCoinOrder::getAdminId,admin1.getId());
+            }
+            if(StringUtils.isNotEmpty(payType)){
+                query.eq(TCoinOrder::getPayType,payType);
+            }
+            if(StringUtils.isNotEmpty(productNo)){
+                query.eq(TCoinOrder::getProductNo,productNo);
+            }
+            if(StringUtils.isNotEmpty(clientId)){
+                TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
+                //判断机器是否属于这个登陆账号
+                if(admin.getType()>1){
+                    //商家
+                    if(equipment.getAdminId().toString().equals(admin.getId().toString())){
+                        query.eq(TCoinOrder::getClientId,equipment.getClientId());
+                    }
+                }else {
+                    query.eq(TCoinOrder::getClientId,equipment.getClientId());
+                }
+            }
+            if(stratDate!=null&&endDate!=null){
+                query.gt(TCoinOrder::getPayDate,stratDate);
+                query.lt(TCoinOrder::getPayDate,endDate);
+            }
+            Page<TCoinOrder> page = new Page<>(current, size, true);
+            IPage<TCoinOrder> iPage = coinOrderService.page(page, query);
+            return R.ok(iPage);
+        }
+        return R.ok();
+    }
+    /**
+     * 判断查询用户是否为外国
+     * @return
+     */
+    private String isForeignUser(String userId){
+        if(StringUtils.isNotEmpty(userId)){
+            try {
+                TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(userId));
+                return admin.getIfForeign();
+            } catch (NumberFormatException e) {
+            }
+        }
+        return "0";
+    }
+    @PostMapping("/getStatistics")
+    public ResponseEntity<?> getStatistics(@RequestBody StatisticsParam param) {
+        //  判断是否为外国
+        param.setIfForeign(isForeignUser(param.getAdminId()));
+        log.info("param:{}", param);
+
+        FgObjectUtil.objectNullOrEmptySel(param, "chartType$");
+        ChartColumn chartColumn = new ChartColumn();
+        if(StringUtils.isNotEmpty(param.getIfForeign())&&param.getIfForeign().equals("1")){
+            if(StringUtils.isNotEmpty(param.getPayType())&&param.getPayType().equals("All")){
+                param.setPayType(null);
+            }
+            //国外查MYSQL
+            chartColumn  = orderService.getStatistics(param);
+        }else{
+            //查去年的数据找数据库
+            String endDate = param.getEndDate();
+            String toYear = "2022-01-01 00:00:00";
+            Date date = new Date();
+            Date year = new Date();
+            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            try {
+                //使用SimpleDateFormat的parse()方法生成Date
+                date = sf.parse(endDate);
+                year = sf.parse(toYear);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            if(date.getTime()<year.getTime()){
+                chartColumn  = orderService.getStatistics(param);
+            }else {
+                if (ElasticsearchRunner.ES_RUNNING) {
+                    try {
+                        // 查es
+                        chartColumn = esTOrderService.getStatistics(param);
+                    }catch (Exception e){
+                        log.error("使用es 查询发生错误:{}",e);
+                        // 查 mysql
+//                    chartColumn  = tOrderService.getStatistics(param);
+                    }
+                }else{
+                    // 查 mysql
+//                chartColumn  = tOrderService.getStatistics(param);
+                }
+            }
+
+        }
+//		if (ElasticsearchRunner.ES_RUNNING) {
+//			try {
+//				// 查es
+//				chartColumn = esTOrderService.getStatistics(param);
+//			}catch (Exception e){
+//				log.error("使用es 查询发生错误:{}",e);
+//				// 查 mysql
+//				chartColumn  = tOrderService.getStatistics(param);
+//			}
+//		}else{
+//			// 查 mysql
+//			chartColumn  = tOrderService.getStatistics(param);
+//		}
+        return ResponseEntity
+                .status(HttpStatus.OK)
+                .body(new ResultMessage()
+                        .setCode(true)
+                        .setData(chartColumn)
+                        .setMessage("SUCCESS"));
+    }
+    /**
+     *  统计 机器销售排行
+     * @param param
+     * @return
+     */
+    @PostMapping("/getEquipmentStatistics")
+    public ResponseEntity<?> getEquipmentStatistics(@RequestBody StatisticsParam param) {
+        //  判断是否为外国
+        param.setIfForeign(isForeignUser(param.getAdminId()));
+        log.info("param:{}", param);
+        FgObjectUtil.objectNullOrEmptySel(param, "chartType$");
+        ChartColumn chartColumn = new ChartColumn();
+//        if(StringUtils.isNotEmpty(param.getIfForeign())&&param.getIfForeign().equals("1")){
+//            //国外查MYSQL
+//            chartColumn = tOrderService.getEquipmentStatistics(param);
+//        }else{
+//            if (ElasticsearchRunner.ES_RUNNING) {
+//                try {
+//                    // 查es
+//                    chartColumn = esTEquipmentService.getEquipmentStatistics(param);
+//                }catch (Exception e){
+//                    log.error("使用es 查询发生错误:{}",e);
+//                    // 查 mysql
+////                    chartColumn = tOrderService.getEquipmentStatistics(param);
+//                }
+//            }else{
+//                // 查 mysql
+////                chartColumn = tOrderService.getEquipmentStatistics(param);
+//            }
+//        }
+        try {
+            // 查es
+            chartColumn = esTEquipmentService.getEquipmentStatistics(param);
+        }catch (Exception e){
+            log.error("使用es 查询发生错误:{}",e);
+            // 查 mysql
+//                    chartColumn = tOrderService.getEquipmentStatistics(param);
+        }
+//        if (ElasticsearchRunner.ES_RUNNING) {
+//            try {
+//                // 查es
+//                chartColumn = esTEquipmentService.getEquipmentStatistics(param);
+//            }catch (Exception e){
+//                log.error("使用es 查询发生错误:{}",e);
+//                // 查 mysql
+//                chartColumn = tOrderService.getEquipmentStatistics(param);
+//            }
+//        }else{
+//            // 查 mysql
+//            chartColumn = tOrderService.getEquipmentStatistics(param);
+//        }
+
+        return ResponseEntity
+                .status(HttpStatus.OK)
+                .body(new ResultMessage()
+                        .setCode(true)
+                        .setData(chartColumn)
+                        .setMessage("SUCCESS"));
+    }
 }
 

+ 13 - 0
src/main/java/com/szwl/feign/SzwlFeign.java

@@ -2,6 +2,9 @@ package com.szwl.feign;
 
 import com.szwl.feign.bean.TAdminParam;
 import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TAdmin;
+import com.szwl.model.entity.TAdminEquipment;
+import com.szwl.model.entity.TEquipment;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 
@@ -13,4 +16,14 @@ public interface SzwlFeign {
 
     @GetMapping("/test/testList")
     public ResponseModel<List<?>> testList(TAdminParam param);
+    @GetMapping("/tAdmin/getAdminIdList")
+    ResponseModel<List<Long>>  getAdminIdList(String adminId);
+    @GetMapping("/tAdmin/getAdminByUsername")
+    ResponseModel<TAdmin>  getAdminByUsername(String username);
+    @GetMapping("/tAdmin/getAdmin")
+    ResponseModel<TAdmin>  getAdmin(String id);
+    @GetMapping("/tEquipment/getClientIdList")
+    ResponseModel<TAdminEquipment>  getClientIdList(String adminId);
+    @GetMapping("/tEquipment/findEquipmentByClientId")
+    ResponseModel<TEquipment> findEquipmentByClientId(String clientId);
 }

+ 8 - 0
src/main/java/com/szwl/mapper/TOrderMapper.java

@@ -1,7 +1,11 @@
 package com.szwl.mapper;
 
+import com.szwl.model.bean.ChartBean;
 import com.szwl.model.entity.TOrder;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.szwl.model.query.StatisticsParam;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TOrderMapper extends BaseMapper<TOrder> {
 
+    public List<ChartBean> getDayStatistics(StatisticsParam param);
+    public List<ChartBean> getWeekStatistics(StatisticsParam param);
+    public List<ChartBean> getMonthStatistics(StatisticsParam param);
+    public List<ChartBean> getYearStatistics(StatisticsParam param);
 }

+ 205 - 1
src/main/java/com/szwl/mapper/xml/TOrderMapper.xml

@@ -36,10 +36,214 @@
         <result column="is_settlement" property="isSettlement" />
         <result column="proportion_desc" property="proportionDesc" />
     </resultMap>
-
+    <resultMap id="chartBean" type="com.szwl.model.bean.ChartBean">
+        <result column="categorie" jdbcType="VARCHAR" property="categorie" />
+        <!--<result column="saleNum" jdbcType="INTEGER" property="saleNum" />-->
+        <result column="saleNum" jdbcType="FLOAT" property="saleNum" />
+        <!--<result column="salePrice" jdbcType="DECIMAL" property="salePrice" />-->
+        <result column="salePrice" jdbcType="FLOAT" property="salePrice" />
+    </resultMap>
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, create_date, modify_date, admin_id, admin_proportion, agency_id, agency_proportion, alt_info, client_id, equipment_id, frp_code, merchant_id, merchant_proportion, pay_date, personage_id, personage_proportion, price, product_id, product_name, refund_date, sn, status, type, trx_no, refund_trx_no, es, refund_amount, note, pay_platform, is_settlement, proportion_desc
     </sql>
 
+    <!-- 日统计select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice -->
+    <select id="getDayStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_order a where a.status='1' -- 支付成功
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            select concat(DATE_FORMAT( a.pay_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_coin_order a  where 1=1
+        </if>
+        <if test="adminId != null and adminId !=''">
+            and a.admin_id= #{adminId} -- 所属商家id
+        </if>
+        <if test="agencyId != null and agencyId !=''">
+            and a.agency_id= #{agencyId} and a.type > '1'
+        </if>
+        <if test="merchantId != null and merchantId !=''">
+            and a.merchant_id= #{merchantId} and a.type > '2'
+        </if>
+        <if test="equipmentId != null and equipmentId !=''">
+            <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+                and a.equipment_id= #{equipmentId} -- 设备id
+            </if>
+            <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+                and a.client_id= #{clientId} -- 设备编号
+            </if>
+        </if>
+        <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
+            and a.pay_type= #{payType} -- 国外支付方式
+        </if>
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
+            group by DATE_FORMAT( a.create_date,'%H')
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            and DATE_FORMAT( a.pay_date,'%Y/%m/%d') = #{startDate}
+            group by DATE_FORMAT( a.pay_date,'%H')
+        </if>
+        order by categorie
+    </select>
+    <!--and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}-->
+    <!--group by DATE_FORMAT( a.create_date,'%H')-->
+    <!-- 周统计 -->
+    <select id="getWeekStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
+        SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
+        select '周1' as categorie from dual UNION all
+        select '周2' as categorie from dual UNION all
+        select '周3' as categorie from dual UNION all
+        select '周4' as categorie from dual UNION all
+        select '周5' as categorie from dual UNION all
+        select '周6' as categorie from dual UNION all
+        select '周日' as categorie from dual) tab1
+        left join (
+        --     select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
+        --     count(1) as saleNum,sum(a.price) as salePrice
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
+            count(1) as saleNum,sum(a.price) as salePrice
+            from t_order a where a.status='1' -- 支付成功
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            select case DATE_FORMAT( a.pay_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.pay_date,'%w')) end as categorie,
+            count(1) as saleNum,sum(a.price) as salePrice
+            from t_coin_order a  where 1=1
+        </if>
+        <if test="adminId != null and adminId !=''">
+            and a.admin_id= #{adminId} -- 所属商家id
+        </if>
+        <if test="agencyId != null and agencyId !=''">
+            and a.agency_id= #{agencyId} and a.type > '1'
+        </if>
+        <if test="merchantId != null and merchantId !=''">
+            and a.merchant_id= #{merchantId} and a.type > '2'
+        </if>
+        <if test="equipmentId != null and equipmentId !=''">
+            <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+                and a.equipment_id= #{equipmentId} -- 设备id
+            </if>
+            <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+                and a.client_id= #{clientId} -- 设备编号
+            </if>
+        </if>
+        <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
+            and a.pay_type= #{payType} -- 国外支付方式
+        </if>
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.create_date,'%w')
+            ) tab2 on tab1.categorie = tab2.categorie
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.pay_date,'%w')
+            ) tab2 on tab1.categorie = tab2.categorie
+        </if>
+    </select>
+
+    <!-- 月统计 -->
+    <select id="getMonthStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            select DATE_FORMAT( a.create_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_order a where a.status='1' -- 支付成功
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            select DATE_FORMAT( a.pay_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_coin_order a  where 1=1
+        </if>
+        <if test="adminId != null and adminId !=''">
+            and a.admin_id= #{adminId} -- 所属商家id
+        </if>
+        <if test="agencyId != null and agencyId !=''">
+            and a.agency_id= #{agencyId} and a.type > '1'
+        </if>
+        <if test="merchantId != null and merchantId !=''">
+            and a.merchant_id= #{merchantId} and a.type > '2'
+        </if>
+        <if test="equipmentId != null and equipmentId !=''">
+            <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+                and a.equipment_id= #{equipmentId} -- 设备id
+            </if>
+            <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+                and a.client_id= #{clientId} -- 设备编号
+            </if>
+        </if>
+        <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
+            and a.pay_type= #{payType} -- 国外支付方式
+        </if>
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.create_date,'%m月%d')
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.pay_date,'%m月%d')
+        </if>
+    </select>
+
+    <!-- 年统计 -->
+    <select id="getYearStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
+        SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
+        select '01月' as categorie from dual UNION all
+        select '02月' as categorie from dual UNION all
+        select '03月' as categorie from dual UNION all
+        select '04月' as categorie from dual UNION all
+        select '05月' as categorie from dual UNION all
+        select '06月' as categorie from dual UNION all
+        select '07月' as categorie from dual UNION all
+        select '08月' as categorie from dual UNION all
+        select '09月' as categorie from dual UNION all
+        select '10月' as categorie from dual UNION all
+        select '11月' as categorie from dual UNION all
+        select '12月' as categorie from dual) tab1
+        left join (
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            select concat(DATE_FORMAT( a.create_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_order a where a.status='1' -- 支付成功
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            select concat(DATE_FORMAT( a.pay_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice
+            from t_coin_order a  where 1=1
+        </if>
+        <if test="adminId != null and adminId !=''">
+            and a.admin_id= #{adminId} -- 所属商家id
+        </if>
+        <if test="agencyId != null and agencyId !=''">
+            and a.agency_id= #{agencyId} and a.type > '1'
+        </if>
+        <if test="merchantId != null and merchantId !=''">
+            and a.merchant_id= #{merchantId} and a.type > '2'
+        </if>
+        <if test="equipmentId != null and equipmentId !=''">
+            <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+                and a.equipment_id= #{equipmentId} -- 设备id
+            </if>
+            <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+                and a.client_id= #{clientId} -- 设备编号
+            </if>
+        </if>
+        <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
+            and a.pay_type= #{payType} -- 国外支付方式
+        </if>
+        <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
+            AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.create_date,'%m')
+            ) tab2 on tab1.categorie = tab2.categorie
+        </if>
+        <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
+            AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
+            <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
+            group by DATE_FORMAT( a.pay_date,'%m')) tab2 on tab1.categorie = tab2.categorie
+        </if>
+    </select>
+
 </mapper>

+ 27 - 0
src/main/java/com/szwl/model/bean/ChartBean.java

@@ -0,0 +1,27 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class ChartBean {
+
+    @ApiModelProperty(value="统计类目")
+    private String categorie;
+
+    @ApiModelProperty(value="销量")
+//    private Integer saleNum;
+    private Float saleNum;
+
+    @ApiModelProperty(value="销售额")
+//    private Integer salePrice;
+    private Float salePrice;
+}

+ 58 - 0
src/main/java/com/szwl/model/bean/ChartColumn.java

@@ -0,0 +1,58 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.List;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class ChartColumn {
+    @ApiModelProperty(value="统计类目")
+    private ArrayList<String> categories;
+    @ApiModelProperty(value="统计类目值")
+    private ArrayList<ChartSerie> series;
+
+    public ChartColumn(List<ChartBean>  list){
+        ArrayList<String> categories = new ArrayList<>();
+//        ArrayList<Integer> salePriceList = new ArrayList<>();
+        ArrayList<Float> salePriceList = new ArrayList<>();
+//        ArrayList<Integer> saleNumList = new ArrayList<>();
+        ArrayList<Float> saleNumList = new ArrayList<>();
+
+        for (ChartBean bean :list) {
+            categories.add(bean.getCategorie());
+            saleNumList.add(bean.getSaleNum());
+            salePriceList.add(Float.valueOf(format1(bean.getSalePrice())));
+        }
+
+        this.setCategories(categories);
+        ChartSerie chartSerie = new ChartSerie();
+        chartSerie.setName("销售个数");
+        chartSerie.setData(saleNumList);
+
+        ChartSerie chartSerie2 = new ChartSerie();
+        chartSerie2.setName("销售额");
+        chartSerie2.setData(salePriceList);
+
+        ArrayList<ChartSerie> series = new ArrayList<>();
+        series.add(chartSerie);
+        series.add(chartSerie2);
+        this.setSeries(series);
+    }
+    public static String format1(Float value){
+        BigDecimal bd = new BigDecimal(value);//创建一个bd对象,将要转换的值value传入构造函数
+        bd = bd.setScale(2, RoundingMode.HALF_UP);//调用setScale方法进行数据格式化,保留两位小数,采用四舍五入规则
+        return bd.toString(); //返回bd对象的值(转化为string形式)
+    }
+}

+ 25 - 0
src/main/java/com/szwl/model/bean/ChartSerie.java

@@ -0,0 +1,25 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.ArrayList;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class ChartSerie {
+
+    @ApiModelProperty(value="类别名")
+    private String name;
+
+    @ApiModelProperty(value="数量")
+//    private ArrayList<Integer> data;
+    private ArrayList<Float> data;
+}

+ 48 - 0
src/main/java/com/szwl/model/bean/Child.java

@@ -0,0 +1,48 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class Child {
+    @ApiModelProperty(value="id")
+    private Long id;
+    @ApiModelProperty(value="名称")
+    private String name;
+    @ApiModelProperty(value="机器列表")
+    private List<Childlast> children;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<Childlast> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<Childlast> children) {
+        this.children = children;
+    }
+}

+ 36 - 0
src/main/java/com/szwl/model/bean/Childlast.java

@@ -0,0 +1,36 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class Childlast {
+    @ApiModelProperty(value="id")
+    private Long id;
+    @ApiModelProperty(value="名称")
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 29 - 0
src/main/java/com/szwl/model/bean/Children2.java

@@ -0,0 +1,29 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+import java.util.Set;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class Children2 {
+    @ApiModelProperty(value="id")
+    private Long id;
+    @ApiModelProperty(value="名称")
+    private String name;
+    @ApiModelProperty(value="商家列表")
+    private List<Child> children;
+    @ApiModelProperty(value="属于该市的所有id")
+    private Set<Long> city;
+    @ApiModelProperty(value="销售数据")
+    private String money;
+}

+ 29 - 0
src/main/java/com/szwl/model/bean/Children3.java

@@ -0,0 +1,29 @@
+package com.szwl.model.bean;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+import java.util.Set;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class Children3 {
+    @ApiModelProperty(value="id")
+    private Long id;
+    @ApiModelProperty(value="名称")
+    private String name;
+    @ApiModelProperty(value="市级列表")
+    private List<Children2> children;
+    @ApiModelProperty(value="属于该省的所有id")
+    private Set<Long> province;
+    @ApiModelProperty(value="销售数据")
+    private String money;
+}

+ 70 - 0
src/main/java/com/szwl/model/bean/CommonParamVo.java

@@ -0,0 +1,70 @@
+package com.szwl.model.bean;
+
+
+import java.util.List;
+
+public class CommonParamVo {
+
+    private String name;
+    /**
+     * 参数值
+     */
+    private String val;
+
+    private List<CommonParamVo> commonParamVos;
+
+    private String id;
+
+    private String code;
+
+    private String clientId;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getVal() {
+        return val;
+    }
+
+    public void setVal(String val) {
+        this.val = val;
+    }
+
+    public List<CommonParamVo> getCommonParamVos() {
+        return commonParamVos;
+    }
+
+    public void setCommonParamVos(List<CommonParamVo> commonParamVos) {
+        this.commonParamVos = commonParamVos;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+}

+ 92 - 0
src/main/java/com/szwl/model/bean/EquipmentDTO.java

@@ -0,0 +1,92 @@
+package com.szwl.model.bean;
+
+public class EquipmentDTO {
+    /**
+     * 设备唯一码
+     */
+    private String clientId;
+
+    /**
+     * 设备编号
+     */
+    private String sn;
+
+    /**
+     * 设备名称
+     */
+    private String name;
+    /**
+     * 地区完整名称
+     */
+    private String fullName;
+    /**
+     * 经度
+     */
+    private Double longitude;
+
+    /**
+     * 维度
+     */
+    private Double latitude;
+
+    /**
+     * 机器状态   开机为1,关机为0
+     */
+    private Integer eqeStatus;
+
+    public Integer getEqeStatus() {
+        return eqeStatus;
+    }
+
+    public void setEqeStatus(Integer eqeStatus) {
+        this.eqeStatus = eqeStatus;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public String getSn() {
+        return sn;
+    }
+
+    public void setSn(String sn) {
+        this.sn = sn;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getFullName() {
+        return fullName;
+    }
+
+    public void setFullName(String fullName) {
+        this.fullName = fullName;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+}

+ 191 - 0
src/main/java/com/szwl/model/bean/EquipmentVo.java

@@ -0,0 +1,191 @@
+package com.szwl.model.bean;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+public class EquipmentVo {
+
+    /**
+     * 设备唯一码
+     */
+    private String clientId;
+
+    /**
+     * 管理系统ID
+     */
+    private  String managerId;
+
+    /**
+     * 柜内温度
+     */
+    private String cabinetTm;
+
+    /**
+     * 柜内湿度
+     */
+    private  String cabinetHd;
+
+    /**
+     *炉头温度
+     */
+    private String furnaceTm;
+
+    /**
+     *音量
+     */
+    private String volume;
+
+    /**
+     * 炉头转速
+     */
+    private  String furnaceSp;
+
+    /**
+     * 联网方式
+     *
+     */
+    private  String netWorkingMode;
+
+    /**
+     * 上一次心跳时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date lastUpdateTime;
+
+
+    /**
+     * 经度
+     */
+    private Double longitude;
+
+    /**
+     * 维度
+     */
+    private Double latitude;
+
+    /**
+     * 睡眠状态  睡眠为true,不睡眠false
+     */
+    private Boolean is_sleep;
+    /**
+     * 设备状态 开机为1,关机为0
+     */
+    public Integer eqeStatus;
+    /**
+     * 实际上设备id
+     */
+    private String gtClientId;
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public Boolean getIs_sleep() {
+        return is_sleep;
+    }
+
+    public void setIs_sleep(Boolean is_sleep) {
+        this.is_sleep = is_sleep;
+    }
+
+    public Integer getEqeStatus() {
+        return eqeStatus;
+    }
+
+    public void setEqeStatus(Integer eqeStatus) {
+        this.eqeStatus = eqeStatus;
+    }
+
+    public String getVolume() {
+        return volume;
+    }
+
+    public void setVolume(String volume) {
+        this.volume = volume;
+    }
+
+    public String getManagerId() {
+        return managerId;
+    }
+
+    public void setManagerId(String managerId) {
+        this.managerId = managerId;
+    }
+
+    public String getCabinetTm() {
+        return cabinetTm;
+    }
+
+    public void setCabinetTm(String cabinetTm) {
+        this.cabinetTm = cabinetTm;
+    }
+
+    public String getCabinetHd() {
+        return cabinetHd;
+    }
+
+    public void setCabinetHd(String cabinetHd) {
+        this.cabinetHd = cabinetHd;
+    }
+
+    public String getFurnaceTm() {
+        return furnaceTm;
+    }
+
+    public void setFurnaceTm(String furnaceTm) {
+        this.furnaceTm = furnaceTm;
+    }
+
+    public String getFurnaceSp() {
+        return furnaceSp;
+    }
+
+    public void setFurnaceSp(String furnaceSp) {
+        this.furnaceSp = furnaceSp;
+    }
+
+    public String getNetWorkingMode() {
+        return netWorkingMode;
+    }
+
+    public void setNetWorkingMode(String netWorkingMode) {
+        this.netWorkingMode = netWorkingMode;
+    }
+
+    public Date getLastUpdateTime() {
+        return lastUpdateTime;
+    }
+
+    public void setLastUpdateTime(Date lastUpdateTime) {
+        this.lastUpdateTime = lastUpdateTime;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public String getGtClientId() {
+        return gtClientId;
+    }
+
+    public void setGtClientId(String gtClientId) {
+        this.gtClientId = gtClientId;
+    }
+}

+ 100 - 0
src/main/java/com/szwl/model/bean/ProductVo.java

@@ -0,0 +1,100 @@
+package com.szwl.model.bean;
+
+
+public class ProductVo implements Comparable<ProductVo> {
+
+    /**
+     * 个推
+     */
+    private String clientId;
+
+    /**
+     * 人名币价格
+     */
+    private Double rmbPrice;
+
+    /**
+     * 投币价格
+     */
+    private Double codePrice;
+
+    /**
+     * 销售状态 true正常销售
+     * false:已售罄
+     */
+    private Boolean sellStatus;
+
+    /**
+     * 产品名称
+     */
+    private String productName;
+
+    /**
+     * 是否显示  0:显示 1:屏蔽
+     */
+    private String showType;
+
+    private String id;
+
+    public String getShowType() {
+        return showType;
+    }
+
+    public void setShowType(String showType) {
+        this.showType = showType;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public Double getRmbPrice() {
+        return rmbPrice;
+    }
+
+    public void setRmbPrice(Double rmbPrice) {
+        this.rmbPrice = rmbPrice;
+    }
+
+    public Double getCodePrice() {
+        return codePrice;
+    }
+
+    public void setCodePrice(Double codePrice) {
+        this.codePrice = codePrice;
+    }
+
+    public Boolean getSellStatus() {
+        return sellStatus;
+    }
+
+    public void setSellStatus(Boolean sellStatus) {
+
+        this.sellStatus = sellStatus;
+    }
+
+    @Override
+    public int compareTo(ProductVo o) {
+        return this.getId().compareTo(o.getId());
+    }
+}

+ 22 - 0
src/main/java/com/szwl/model/bean/TAdminDTO.java

@@ -0,0 +1,22 @@
+package com.szwl.model.bean;
+
+import com.szwl.model.entity.TAdmin;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class TAdminDTO extends TAdmin {
+
+	@ApiModelProperty(value="设备列表")
+	private List<TEquipmentDTO> equipmentList;
+}

+ 68 - 0
src/main/java/com/szwl/model/bean/TEquipmentDTO.java

@@ -0,0 +1,68 @@
+package com.szwl.model.bean;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.szwl.model.entity.TAlarmRecord;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.utils.DateUtils;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@ToString
+public class TEquipmentDTO extends TEquipment {
+    @ApiModelProperty(value="所以报警信息")
+    private List<TAlarmRecord> alarmList;
+    @ApiModelProperty(value="最新报警信息")
+    private String alarmContent = "暂无数据";
+
+    @ApiModelProperty(value="当天是否存在告警")
+    private boolean hasTodayAlarm= false;
+
+    public List<TAlarmRecord> getAlarmList() {
+        return alarmList;
+    }
+
+    public void setAlarmList(List<TAlarmRecord> alarmList) {
+        this.alarmList = alarmList;
+    }
+
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="报警发生时间")
+
+    private Date occurrenceTime;
+
+    public String getAlarmContent() {
+        return alarmContent;
+    }
+
+    public void setAlarmContent(String alarmContent) {
+        this.alarmContent = alarmContent;
+    }
+
+    public boolean isHasTodayAlarm() {
+        return hasTodayAlarm;
+    }
+
+    public void setHasTodayAlarm(boolean hasTodayAlarm) {
+        this.hasTodayAlarm = hasTodayAlarm;
+    }
+
+    public Date getOccurrenceTime() {
+        return occurrenceTime;
+    }
+
+    public void setOccurrenceTime(Date occurrenceTime) {
+        if(null != occurrenceTime){
+            this.hasTodayAlarm = DateUtils.isSameDay(new Date(),occurrenceTime);
+            this.occurrenceTime = occurrenceTime;
+        }
+    }
+}

+ 20 - 0
src/main/java/com/szwl/model/bo/ChartType.java

@@ -0,0 +1,20 @@
+package com.szwl.model.bo;
+
+public enum ChartType {
+	/**
+	 * 日统计
+	 */
+	day,
+	/**
+	 * 周统计
+	 */
+	week,
+	/**
+	 * 月统计
+	 */
+	month,
+	/**
+	 * 年统计
+	 */
+	year
+}

+ 321 - 0
src/main/java/com/szwl/model/bo/JsonMessage.java

@@ -0,0 +1,321 @@
+package com.szwl.model.bo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.collection.AbstractPersistentCollection;
+
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * Created by study on 9/2/2015.
+ */
+public final class JsonMessage {
+    /**
+     * 用户未登录
+     */
+    public static final JsonMessage USER_NOT_LOGIN = JsonMessage.error(2, "用户未登录");
+    /**
+     * 未知错误
+     */
+    public static final JsonMessage UNKNOWN_ERROR = JsonMessage.error(4, "未知错误");
+
+    /**
+     * 成功代码
+     */
+    public static final int CODE_SUCCESS = 0;
+
+    /**
+     * 基本错误代码
+     */
+    public static final int CODE_ERROR = 1;
+
+    /**
+     * 返回码
+     */
+    @JsonProperty
+    private int code;
+
+    /**
+     * 错误信息
+     */
+    @JsonProperty
+    private Object errmsg;
+
+    /**
+     * 返回数据
+     */
+    @JsonProperty
+    private Object data;
+
+    // 禁止创建对象
+    private JsonMessage(int code, Object data) {
+        this.code = code;
+        if ( code== 0 ){
+            this.data = data;
+        } else {
+            this.errmsg = data;
+        }
+    }
+
+    /**
+     * /**
+     * 成功消息(code=0)<br>
+     * 单参数返回格式为:{code:0,data:<Object>}<br>
+     * 多参数格式:参数名1,参数值1,参数名2,参数值2...<br>
+     * 返回Json格式{code:0,data:{'参数1':参数值1(Object),'参数2':参数值2(Object)}}
+     *
+     * @param data 数据组
+     * @return
+     */
+    public static JsonMessage success(Object... data) {
+        return message(CODE_SUCCESS, data);
+    }
+
+    /**
+     * 失败消息(code=1)<br>
+     * 单参数返回格式为:{code:1,data:<Object>}<br>
+     * 多参数格式:参数名1,参数值1,参数名2,参数值2...<br>
+     * 返回Json格式{code:1,data:{'参数1':参数值1(Object),'参数2':参数值2(Object)}}
+     *
+     * @param data 失败消息
+     * @return
+     */
+    public static JsonMessage error(Object data) {
+        return message(CODE_ERROR, data);
+    }
+
+    /**
+     * 失败消息(code=1)<br>
+     * 单参数返回格式为:{code:1,data:<Object>}<br>
+     * 多参数格式:参数名1,参数值1,参数名2,参数值2...<br>
+     * 返回Json格式{code:1,data:{'参数1':参数值1(Object),'参数2':参数值2(Object)}}
+     *
+     * @param data 失败消息
+     * @return
+     */
+    public static JsonMessage error(int code, Object data) {
+        return message(code, data);
+    }
+
+    /**
+     * 通用消息消息<br>
+     * 单参数返回格式为:{code:code(int),data:<Object>}<br>
+     * 多参数格式:参数名1,参数值1,参数名2,参数值2...<br>
+     * 返回Json格式{code:code(int),data:{'参数1':参数值1(Object),'参数2':参数值2(Object)}}
+     *
+     * @param code 返回码
+     * @param data 返回数据,支持多数据返回,多数据参数格式:参数名1(String),参数值1(Object),参数名2(String),参数值2(Object)...
+     * @return
+     */
+    private static JsonMessage message(int code, Object... data) {
+        if (data == null) data = new Object[]{new Object()};
+        if (data.length == 1) {
+            // 单一数据
+            return new JsonMessage(code, data[0]);
+        } else {
+            Map<String, Object> map = new LinkedHashMap<>();
+
+            for (int i = 0; i < data.length; i++) {
+                String key = data[i++].toString();
+                map.put(key, data[i]);
+            }
+            return new JsonMessage(code, map);
+        }
+    }
+
+    /**
+     * 优化对象数据
+     *
+     * @param bean
+     * @param properties
+     * @return
+     */
+    public static Object optimiseObj(Object bean, String... properties) {
+        Map<String, Object> map = new HashMap<>();
+        if (bean == null) {
+            //TODO 前端需要null
+            return null;
+            // TODO 前端需要空对象
+//            return map;
+        }
+        // 判断是否列表
+        if (isCollection(bean.getClass())) {
+            Collection list = (Collection) bean;
+            return optimiseList(list, properties);
+        }
+        // 2. 循环每一个属性
+        for (String string : properties) {
+            if (StringUtils.isEmpty(string)) continue;
+            // 处理级联属性
+            String[] names = string.split("\\.");
+            Map<String, Object> tmp = map;
+            Map<String, Object> field;
+            // 3. 循环每一个级联属性
+            StringBuilder prefix = new StringBuilder();
+            for (int i = 0; i < names.length; i++) {
+                if (i == (names.length - 1)) {
+                    // 最后一个field
+                    tmp.put(names[i], getPropertyValue(bean, string));
+                } else {
+                    field = (Map<String, Object>) tmp.get(names[i]);
+                    if (field == null) {
+                        field = new HashMap<>();
+                        tmp.put(names[i], field);
+                    }
+                    prefix.append(names[i]);
+                    // 处理list
+                    Class type = getPropertyType(bean, prefix.toString());
+                    Object obj = getPropertyObject(bean, prefix.toString());
+                    prefix.append(".");//必须在这里添加
+                    if (obj == null) {
+                        tmp.put(names[i], null);
+                        break;
+                    } else if (isCollection(type)) {
+                        String suffix = string.replace(prefix.toString(), "");
+                        tmp.put(names[i], optimiseList((Collection) getPropertyObject(bean, prefix.substring(0, prefix.length() - 1)), suffix.split("#")));
+                        break;
+                    }
+
+                    tmp = field; // 必须在处理list之后修改
+                }
+            }
+        }
+
+        return map;
+    }
+
+    /**
+     * 优化列表数据
+     *
+     * @param list       列表
+     * @param properties 需要的属性
+     * @return
+     */
+    private static Object optimiseList(Collection list, String... properties) {
+        List<Object> newList = new ArrayList<>();
+        if (list != null && properties != null) {
+            // 1. 循环每一个list item
+            for (Object bean : list) {
+                newList.add(optimiseObj(bean, properties));
+            }
+        }
+
+        return newList;
+    }
+
+    /**
+     * 反射获取字段值,支持级联
+     *
+     * @param bean
+     * @param property
+     * @return
+     */
+    private static Object getPropertyValue(Object bean, String property) {
+        try {
+            Class type = getPropertyType(bean, property);
+            if (isCollection(type)) {
+                return BeanUtils.getArrayProperty(bean, property);
+            } else {
+                return BeanUtils.getProperty(bean, property);
+            }
+        } catch (Exception e) {
+        }
+
+        return null;
+    }
+
+    /**
+     * 获取属性类型,支持级联
+     *
+     * @param bean
+     * @param property
+     * @return
+     */
+    private static Class getPropertyType(Object bean, String property) {
+        try {
+            String[] names = property.split("\\.");
+            Object obj = bean;
+            Method method = null;
+            for (String name : names) {
+                method = obj.getClass().getMethod("get" + toUpperCaseFirstOne(name));
+                obj = method.invoke(obj);
+            }
+
+            return method.getReturnType();
+        } catch (Exception e) {
+        }
+
+        return null;
+    }
+
+    /**
+     * 获取属性对象,支持级联
+     *
+     * @param bean
+     * @param property
+     * @return
+     */
+    private static Object getPropertyObject(Object bean, String property) {
+        try {
+            String[] names = property.split("\\.");
+            Object obj = bean;
+            Method method;
+            for (String name : names) {
+                method = obj.getClass().getMethod("get" + toUpperCaseFirstOne(name));
+                obj = method.invoke(obj);
+            }
+
+            return obj;
+        } catch (Exception e) {
+        }
+
+        return null;
+    }
+
+    /**
+     * 判断类型是否是集合
+     *
+     * @param type
+     * @return
+     */
+    private static boolean isCollection(Class type) {
+//        System.out.println(type);
+        while (type != null && !Object.class.equals(type)) {
+            Class[] classes = type.getInterfaces();
+            for (Class c : classes) {
+                if (Collection.class.equals(c)) {
+                    return true;
+                }
+            }
+
+            if (AbstractCollection.class.equals(type) || AbstractPersistentCollection.class.equals(type)) {
+                return true;
+            } else {
+                type = type.getSuperclass();
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * 首字母转大写
+     *
+     * @param s
+     * @return
+     */
+    private static String toUpperCaseFirstOne(String s) {
+        if (StringUtils.isEmpty(s)) {
+            return "";
+        }
+
+        if (Character.isUpperCase(s.charAt(0))) {
+            return s;
+        } else {
+            return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
+        }
+    }
+
+}

+ 25 - 0
src/main/java/com/szwl/model/bo/ParamNotFoundException.java

@@ -0,0 +1,25 @@
+package com.szwl.model.bo;
+
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+ * 参数不符或缺失时报错
+ * @author 吴洪双
+ */
+@Accessors(chain = true)
+@Setter
+public class ParamNotFoundException extends RuntimeException {
+
+    private static final long serialVersionUID = -2565431806475335331L;
+
+    public ParamNotFoundException(String paramName){
+    	this.paramName = paramName;
+    }
+    private String paramName;
+    @Override
+    public String getMessage() {
+        return paramName + " is not null or empty";
+    }
+
+}

+ 119 - 0
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -0,0 +1,119 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.szwl.model.utils.AdminUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.beans.Transient;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-03-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TAdmin对象", description="")
+public class TAdmin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    private Long areaId;
+
+    @ApiModelProperty(value = "邮箱;")
+    private String email;
+
+    @ApiModelProperty(value = "设置是否普通管理员(0:管理员,1:子账户);")
+    private Boolean isAdmined;
+
+    @ApiModelProperty(value = "是否启用;")
+    private Boolean isEnabled;
+
+    @ApiModelProperty(value = "是否锁定;")
+    private Boolean isLocked;
+
+    @ApiModelProperty(value = "锁定时间;")
+    private Date lockedDate;
+
+    @ApiModelProperty(value = "登录时间;")
+    private Date loginDate;
+
+    @ApiModelProperty(value = "连续登录失败次数;")
+    private Integer loginFailureCount;
+
+    private String loginIp;
+
+    @ApiModelProperty(value = "商户报备号;")
+    private String tradeMerchantNo;
+
+    private String name;
+
+    @ApiModelProperty(value = "如果is_admined=1,说明这个账户是子账户,它的拥有者的adminId就是parent_id;")
+    private Long parentId;
+
+    private String password;
+
+    @ApiModelProperty(value = "当前查看过公告的id;")
+    private Long noticeId;
+
+    @ApiModelProperty(value = "类型,0:超管,1,公司人员;2:商家,3:商家子账户")
+    private Integer type;
+
+    @ApiModelProperty(value = "登录名;")
+    private String username;
+
+    @ApiModelProperty(value = "电话;")
+    private String phone;
+
+    @ApiModelProperty(value = "是否退款;")
+    private String isRefund;
+
+    @ApiModelProperty(value = "是否国外;0:国内,1:国外")
+    private String ifForeign;
+
+    @ApiModelProperty(value = "是否开启远程开关机")
+    private String open;
+
+    @ApiModelProperty(value = "是否开通0折优惠码;0:开通;1:关闭")
+    private String promoCodeOpen;
+
+    @ApiModelProperty(value = "机器连接服务器免审核开始时间")
+    private Date applyStartTime;
+
+    @ApiModelProperty(value = "机器连接服务器免审核结束时间")
+    private Date applyEndTime;
+
+    @ApiModelProperty(value = "短信验证码;")
+    private String code;
+
+    @ApiModelProperty(value = "支付平台; 0或null为汇聚,1为杉德支付")
+    private String payPlatform;
+
+    @ApiModelProperty(value = "关联商家,相当于以前的parent_id")
+    private String relationAdminId;
+    @Transient
+    public String getManagerId() {
+
+        String managerId = "";
+
+        managerId = AdminUtils.encrypt(false, this.getId());
+        return managerId;
+    }
+
+}

+ 33 - 0
src/main/java/com/szwl/model/entity/TAdminEquipment.java

@@ -0,0 +1,33 @@
+package com.szwl.model.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-07-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TAdminEquipment对象", description="")
+public class TAdminEquipment implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long adminId;
+
+    private String equipmentIds;
+
+    @ApiModelProperty(value = "0:全部机器,1:部分机器")
+    private String type;
+
+
+}

+ 75 - 0
src/main/java/com/szwl/model/entity/TAlarmRecord.java

@@ -0,0 +1,75 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 报警信息
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TAlarmRecord对象", description="报警信息")
+public class TAlarmRecord implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    @ApiModelProperty(value = "报警内容;")
+    private String alarmContent;
+
+    @ApiModelProperty(value = "设备编号;")
+    private String clientId;
+
+    @ApiModelProperty(value = "标记;")
+    private String remark;
+
+    @ApiModelProperty(value = "用户级别;")
+    private String adminLevel;
+
+    @ApiModelProperty(value = "设备id;")
+    private Long equipmentId;
+
+    @ApiModelProperty(value = "名称;")
+    private String name;
+
+    @ApiModelProperty(value = "发生时间;")
+    private Date occurrenceTime;
+
+    @ApiModelProperty(value = "用户id;")
+    private Long adminId;
+
+    @ApiModelProperty(value = "用户名;")
+    private String adminUserName;
+
+    private Long agencyId;
+
+    private Long merchantId;
+
+    private Long personageId;
+
+    @ApiModelProperty(value = "级别(省,市,终端);")
+    private Integer type;
+
+    @ApiModelProperty(value = "报警是否消除;0:没有,1:已消除")
+    private Integer isEliminate;
+
+
+}

+ 3 - 0
src/main/java/com/szwl/model/entity/TCoinOrder.java

@@ -53,6 +53,9 @@ public class TCoinOrder implements Serializable {
     @ApiModelProperty(value = "商品名称;")
     private String productName;
 
+    @ApiModelProperty(value = "商品名称;")
+    private String productNo;
+
     @ApiModelProperty(value = "是否发送到es报存;")
     private String es;
 

+ 176 - 0
src/main/java/com/szwl/model/entity/TEquipment.java

@@ -0,0 +1,176 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 设备表
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-04-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TEquipment对象", description="设备表")
+public class TEquipment implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Date createDate;
+
+    private Date modifyDate;
+
+    @ApiModelProperty(value = "用户id;")
+    private Long adminId;
+
+    @ApiModelProperty(value = "用户等级;")
+    private String adminLevel;
+
+    @ApiModelProperty(value = "机器超级管理员admin密码;")
+    private String adminPwd;
+
+    private Long areaId;
+
+    @ApiModelProperty(value = "柜内湿度;")
+    private String cabinetHd;
+
+    @ApiModelProperty(value = "炉头温度;")
+    private String cabinetTm;
+
+    @ApiModelProperty(value = "设备编号;")
+    private String clientId;
+
+    @ApiModelProperty(value = "机器联系人名称;")
+    private String contactName;
+
+    @ApiModelProperty(value = "联系人电话;")
+    private String contactPhone;
+
+    @ApiModelProperty(value = "运营者电话;")
+    private String operationalPhone;
+
+    @ApiModelProperty(value = "机器运营者")
+    private String operationalName;
+
+    @ApiModelProperty(value = "炉头转速;")
+    private String furnaceSp;
+
+    @ApiModelProperty(value = "炉头温度;")
+    private String furnaceTm;
+
+    @ApiModelProperty(value = "机器guest密码;")
+    private String guestPwd;
+
+    @ApiModelProperty(value = "true 代表 强制联网使用 ,false 代表 可不联网使用;")
+    private Boolean isNetWork;
+
+    @ApiModelProperty(value = "机器启用状态,true:启用;")
+    private Boolean isUsing;
+
+    @ApiModelProperty(value = "最近刷新时间;")
+    private Date lastUpdateTime;
+
+    @ApiModelProperty(value = "经度;")
+    private Double latitude;
+
+    @ApiModelProperty(value = "纬度;")
+    private Double longitude;
+
+    @ApiModelProperty(value = "管理系统ID;")
+    private String managerId;
+
+    @ApiModelProperty(value = "客户自命名")
+    private String selfName;
+
+    @ApiModelProperty(value = "通信方式; 1:个推,2:Mq 如果为null,那么用个推")
+    private String channel;
+
+    @ApiModelProperty(value = "机器名称;")
+    private String name;
+
+    @ApiModelProperty(value = "联网方式;")
+    private String netWorkingMode;
+
+    @ApiModelProperty(value = "运营商;")
+    private String operator;
+
+    @ApiModelProperty(value = "支付方式;")
+    private Integer payType;
+
+    @ApiModelProperty(value = "销售总数;")
+    private Integer productTotal;
+
+    @ApiModelProperty(value = "SIM卡卡号;")
+    private String simNo;
+
+    @ApiModelProperty(value = "设备编号自命名;")
+    private String sn;
+
+    @ApiModelProperty(value = "所属商家;")
+    private String adminUserName;
+
+    @ApiModelProperty(value = "公司电话;")
+    private String companyPhone;
+
+    @ApiModelProperty(value = "0:分账方2个,1:分账方3个,3:分账方4个,3:分账方超4个;")
+    private Integer type;
+
+    @ApiModelProperty(value = "地址全名;")
+    private String fullName;
+
+    @ApiModelProperty(value = "最后推送时间;")
+    private Date pushUpdateTime;
+
+    @ApiModelProperty(value = "广告规则id;")
+    private Long timeRuleId;
+
+    @ApiModelProperty(value = "实际上的设备id;")
+    private String gtClientId;
+
+    @ApiModelProperty(value = "设备状态 开机为1,关机为0;")
+    private Integer eqeStatus;
+
+    @ApiModelProperty(value = "锁机状态;")
+    private Boolean isBlocked;
+
+    @ApiModelProperty(value = "短信接收者;")
+    private String messageReceiver;
+
+    @ApiModelProperty(value = "睡眠状态,睡眠为true,不睡眠false;")
+    private Boolean isSleep;
+
+    @ApiModelProperty(value = "音量;")
+    private String volume;
+
+    @ApiModelProperty(value = "远程开关机的时间戳")
+    private String network;
+
+    @ApiModelProperty(value = "PLC版本;")
+    private String plcVersion;
+
+    @ApiModelProperty(value = "棉花糖机器类型,mg320,mg301;")
+    private String equimentType;
+
+    @ApiModelProperty(value = "mg280机器到期时间;")
+    private Date endDate;
+
+    @ApiModelProperty(value = "花型数量;")
+    private String flowers;
+
+    @ApiModelProperty(value = "设备类型,0:棉花糖,1,爆米花")
+    private String machineType;
+
+
+}

+ 2 - 1
src/main/java/com/szwl/model/entity/TOrder.java

@@ -79,7 +79,8 @@ public class TOrder implements Serializable {
 
     @ApiModelProperty(value = "商品名称;")
     private String productName;
-
+    @ApiModelProperty(value = "商品编号;")
+    private String productNo;
     @ApiModelProperty(value = "退款时间;")
     private Date refundDate;
 

+ 57 - 0
src/main/java/com/szwl/model/query/StatisticsParam.java

@@ -0,0 +1,57 @@
+package com.szwl.model.query;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class StatisticsParam {
+    @ApiModelProperty(value="商家id")
+    private String adminId;
+
+    @ApiModelProperty(value="设备id")
+    private String equipmentId;
+    @ApiModelProperty(value="设备编号")
+    private String clientId;
+    @ApiModelProperty(value="开关炉头,开机为1,关机为0")
+    private String eqeStatus;
+    @ApiModelProperty(value="代理商id")
+    private Long agencyId;
+
+    @ApiModelProperty(value="经销商id")
+    private Long merchantId;
+
+    @ApiModelProperty(value="地址id")
+    private List<Long> areaIds;
+
+    @ApiModelProperty(value="开始日期")
+    private String startDate;
+
+    @ApiModelProperty(value="结束日期")
+    private String endDate;
+
+    @ApiModelProperty(value="统计类型")
+    private String chartType;
+
+    @ApiModelProperty(value="支付类型")
+    private String payType;
+
+    @ApiModelProperty(value="统计类型")
+    private String changeType;
+
+    @ApiModelProperty(value="是否外国")
+    private String ifForeign = "0";
+
+    @ApiModelProperty(value="第几次查询")
+    private String test = "1";
+}

+ 21 - 0
src/main/java/com/szwl/model/query/TAdminParam.java

@@ -0,0 +1,21 @@
+package com.szwl.model.query;
+
+import com.szwl.model.bo.BasePageQuery;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2022-03-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="查询 TAdmin", description="")
+public class TAdminParam extends BasePageQuery {
+    String name;
+}

+ 60 - 0
src/main/java/com/szwl/model/query/TCoinOrderParam.java

@@ -0,0 +1,60 @@
+/**
+ * Date:2019-09-23 17:09:15
+ * author:吴洪双
+*/
+
+package com.szwl.model.query;
+
+import com.szwl.common.myAnnotation.CamelCaseToUnderscore;
+import com.szwl.model.entity.TCoinOrder;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+@SuppressWarnings("serial")
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class TCoinOrderParam extends TCoinOrder {
+	 @CamelCaseToUnderscore
+     @ApiModelProperty(value = "排序,如:id desc")
+     private String orderByClause;
+    @ApiModelProperty(value = "是否distinct")
+    private boolean distinct;
+    @ApiModelProperty(value = "分页,展示多少条记录")
+    private Integer limit;
+    @ApiModelProperty(value = "分页,从第几条开始,默认从0开始")
+    private Integer offset;
+    @ApiModelProperty(value = "主键id 集合,用于批量删除和批量修改")
+    private List primaryKeyList;
+    private List<TCoinOrder> entityList;//实体集合,用于批量新增
+    
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date createDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date createDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_end;
+    private String clientId_like;
+    private List clientId_inList;
+    private String sn_like;
+    private String createDate_like;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date payDate_start;
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date payDate_end;
+/*==================================以上是自动生成部分字段======================================*/
+    private List adminId_inList;
+    private List productName_notInList;
+}

+ 68 - 0
src/main/java/com/szwl/model/query/TEquipmentParam.java

@@ -0,0 +1,68 @@
+/**
+ * Date:2019-09-23 17:09:15
+ * author:吴洪双
+*/
+
+package com.szwl.model.query;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.szwl.model.entity.TEquipment;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+@SuppressWarnings("serial")
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class TEquipmentParam extends TEquipment {
+	// @CamelCaseToUnderscore
+    // @ApiModelProperty(value = "排序,如:id desc")
+    // private String orderByClause;
+    @ApiModelProperty(value = "是否distinct")
+    private boolean distinct;
+    @ApiModelProperty(value = "分页,展示多少条记录")
+    private Integer limit;
+    @ApiModelProperty(value = "分页,从第几条开始,默认从0开始")
+    private Integer offset;
+    @ApiModelProperty(value = "主键id 集合,用于批量删除和批量修改")
+    private List primaryKeyList;
+    private List<TEquipment> entityList;//实体集合,用于批量新增
+    
+//	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date createDate_start;
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date createDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date lastUpdateTime_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date lastUpdateTime_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date pushUpdateTime_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date pushUpdateTime_end;
+	private String name_like;
+	private String clientId_like;
+	private String adminUserName_like;
+
+	private List clientId_inList;
+	private List id_inList;
+/*==================================以上是自动生成部分字段======================================*/
+	
+}

+ 65 - 0
src/main/java/com/szwl/model/query/TOrderParam.java

@@ -0,0 +1,65 @@
+/**
+ * Date:2019-09-23 17:09:15
+ * author:吴洪双
+*/
+
+package com.szwl.model.query;
+
+import com.szwl.common.myAnnotation.CamelCaseToUnderscore;
+import com.szwl.model.entity.TOrder;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+@SuppressWarnings("serial")
+@Accessors(chain = true)
+@NoArgsConstructor
+@Getter
+@Setter
+@ToString
+public class TOrderParam extends TOrder {
+	 @CamelCaseToUnderscore
+     @ApiModelProperty(value = "排序,如:id desc")
+     private String orderByClause;
+    @ApiModelProperty(value = "是否distinct")
+    private boolean distinct;
+    @ApiModelProperty(value = "分页,展示多少条记录")
+    private Integer limit;
+    @ApiModelProperty(value = "分页,从第几条开始,默认从0开始")
+    private Integer offset;
+    @ApiModelProperty(value = "主键id 集合,用于批量删除和批量修改")
+    private List primaryKeyList;
+    private List<TOrder> entityList;//实体集合,用于批量新增
+
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date createDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date createDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date modifyDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date payDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date payDate_end;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date refundDate_start;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+	private Date refundDate_end;
+	private String clientId_like;
+	private String createDate_like;
+	private String sn_like;
+	private Integer type_gt;
+
+	private List equipmentId_inList;
+/*==================================以上是自动生成部分字段======================================*/
+
+}

+ 80 - 0
src/main/java/com/szwl/model/utils/AESUtil.java

@@ -0,0 +1,80 @@
+package com.szwl.model.utils;
+
+
+
+import com.szwl.model.utils.constants.Algorithm;
+import com.szwl.model.utils.constants.CommonConst;
+import com.szwl.model.utils.exceptions.JPException;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.SecureRandom;
+
+/**
+ * AES加解密工具类
+ * @author chenyf
+ * @date 2018-12-15
+ */
+public class AESUtil {
+    private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding";//算法/模式/补码方式
+
+    public static String encrypt(String content, String password, String ivParam){
+        try {
+            SecretKeySpec secSpec = genSecretKeySpec(password);
+            Cipher cipher = Cipher.getInstance(TRANSFORMATION);
+            IvParameterSpec ivp = new IvParameterSpec(ivParam.getBytes(CommonConst.ENCODING_UTF_8));
+            cipher.init(Cipher.ENCRYPT_MODE, secSpec, ivp);
+            byte[] encrypted = cipher.doFinal(content.getBytes(CommonConst.ENCODING_UTF_8));
+            return HEXUtil.encode(CodeUtil.base64Encode(encrypted));
+        }catch(Throwable e){
+            throw new JPException("AES加密异常", e);
+        }
+    }
+
+    public static String decrypt(String content, String password, String ivParam){
+        try {
+            SecretKeySpec secSpec = genSecretKeySpec(password);
+            Cipher cipher = Cipher.getInstance(TRANSFORMATION);
+            IvParameterSpec ivp = new IvParameterSpec(ivParam.getBytes(CommonConst.ENCODING_UTF_8));
+            cipher.init(Cipher.DECRYPT_MODE, secSpec, ivp);
+            byte[] encrypted1 = CodeUtil.base64Decode(HEXUtil.decode(content));
+            byte[] original = cipher.doFinal(encrypted1);
+            return new String(original, CommonConst.ENCODING_UTF_8);
+        }catch(Throwable e){
+            throw new JPException("AES解密异常", e);
+        }
+    }
+
+    /**
+     * 生成密钥对象 密钥可支持16位或32位(32位是否支持取决于JDK)
+     * @param password
+     * @return
+     * @throws Exception
+     */
+    public static SecretKeySpec genSecretKeySpec(String password) throws Exception{
+        if (password == null || (password.length() != 16 && password.length() != 32)) {
+            throw new JPException("password长度须为16或32位");
+        }
+        KeyGenerator kGen = KeyGenerator.getInstance(Algorithm.AES);
+        SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+        secureRandom.setSeed(password.getBytes());
+        kGen.init(password.length()==16 ? 128 : 256, secureRandom);
+        SecretKey secretKey = kGen.generateKey();
+        byte[] enCodeFormat = secretKey.getEncoded();
+        return new SecretKeySpec(enCodeFormat, Algorithm.AES);
+    }
+
+    public static void main(String[] args){
+        String key = "28E9B48CBCC4E5DB";
+        String iv = "B1177108BAB2BAB3";
+
+        String content1 = "31454E38597073356A6B7778564A54656B374B734B513D3D";
+        String content2 = "626E4B7049662F435A697164766E4D4E5577374C6B773D3D";
+
+        System.out.println("content1 = " + decrypt(content1, key, iv));
+        System.out.println("content2 = " + decrypt(content2, key, iv));
+    }
+}

+ 57 - 0
src/main/java/com/szwl/model/utils/AdminUtils.java

@@ -0,0 +1,57 @@
+/*
+ *
+ *
+ *
+ */
+package com.szwl.model.utils;
+
+/**
+ * 处理id
+ */
+public final class AdminUtils {
+
+    private static final Long base1 = 2452l;
+
+    private static final Long base2 = 13l;
+
+    private static final String prefix = "u";
+
+
+    /**
+     * 将id转成加密样式
+     */
+    public static String encrypt(boolean isPrefix , Long id) {
+        id = id * base2 + base1;
+        if(isPrefix){
+            return prefix + id.toString();
+        }else{
+            return id.toString();
+        }
+
+    }
+
+
+    /**
+     * 解密id
+     */
+    public static Long decrypt(boolean isPrefix , String uid) {
+        try {
+            if(isPrefix){
+                uid = uid.substring(1, uid.length());
+            }
+
+            Long id = Long.valueOf(uid);
+            id = id - base1;
+            id = id / base2;
+            return id;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(encrypt(false, 3L));
+        System.out.println(decrypt(false, "2478"));
+    }
+}

+ 117 - 0
src/main/java/com/szwl/model/utils/Base64Util.java

@@ -0,0 +1,117 @@
+package com.szwl.model.utils;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * base64 format encoding & decoding
+ */
+public class Base64Util {
+	private static char[] base64EncodeChars = new char[] { 'A', 'B', 'C', 'D',
+			'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
+			'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+			'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
+			'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+			'4', '5', '6', '7', '8', '9', '+', '/' };
+
+	private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59,
+			60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+			10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
+			-1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+			38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1,
+			-1, -1 };
+
+	private Base64Util(){
+	}
+
+	public static String encode(byte[] data){
+		StringBuffer sb = new StringBuffer();
+		int len = data.length;
+		int i = 0;
+		int b1, b2, b3;
+
+		while (i < len) {
+			b1 = data[i++] & 0xff;
+			if (i == len) {
+				sb.append(base64EncodeChars[b1 >>> 2]);
+				sb.append(base64EncodeChars[(b1 & 0x3) << 4]);
+				sb.append("==");
+				break;
+			}
+			b2 = data[i++] & 0xff;
+			if (i == len) {
+				sb.append(base64EncodeChars[b1 >>> 2]);
+				sb.append(base64EncodeChars[((b1 & 0x03) << 4)
+						| ((b2 & 0xf0) >>> 4)]);
+				sb.append(base64EncodeChars[(b2 & 0x0f) << 2]);
+				sb.append("=");
+				break;
+			}
+			b3 = data[i++] & 0xff;
+			sb.append(base64EncodeChars[b1 >>> 2]);
+			sb.append(base64EncodeChars[((b1 & 0x03) << 4)
+					| ((b2 & 0xf0) >>> 4)]);
+			sb.append(base64EncodeChars[((b2 & 0x0f) << 2)
+					| ((b3 & 0xc0) >>> 6)]);
+			sb.append(base64EncodeChars[b3 & 0x3f]);
+		}
+		return sb.toString();
+	}
+
+	public static byte[] decode(String str){
+		byte[] data = str.getBytes();
+		int len = data.length;
+		ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
+		int i = 0;
+		int b1, b2, b3, b4;
+
+		while (i < len) {
+
+			/* b1 */
+			do {
+				b1 = base64DecodeChars[data[i++]];
+			} while (i < len && b1 == -1);
+			if (b1 == -1) {
+				break;
+			}
+
+			/* b2 */
+			do {
+				b2 = base64DecodeChars[data[i++]];
+			} while (i < len && b2 == -1);
+			if (b2 == -1) {
+				break;
+			}
+			buf.write(((b1 << 2) | ((b2 & 0x30) >>> 4)));
+
+			/* b3 */
+			do {
+				b3 = data[i++];
+				if (b3 == 61) {
+					return buf.toByteArray();
+				}
+				b3 = base64DecodeChars[b3];
+			} while (i < len && b3 == -1);
+			if (b3 == -1) {
+				break;
+			}
+			buf.write((((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));
+
+			/* b4 */
+			do {
+				b4 = data[i++];
+				if (b4 == 61) {
+					return buf.toByteArray();
+				}
+				b4 = base64DecodeChars[b4];
+			} while (i < len && b4 == -1);
+			if (b4 == -1) {
+				break;
+			}
+			buf.write((((b3 & 0x03) << 6) | b4));
+		}
+		return buf.toByteArray();
+	}
+}

+ 17 - 0
src/main/java/com/szwl/model/utils/CodeUtil.java

@@ -0,0 +1,17 @@
+package com.szwl.model.utils;
+
+/**
+ * 编解码工具类
+ * @author chenyf
+ * @date 2018-12-15
+ */
+public class CodeUtil {
+
+    public static String base64Encode(byte[] value) {
+        return Base64Util.encode(value);
+    }
+
+    public static byte[] base64Decode(String value) {
+        return Base64Util.decode(value);
+    }
+}

+ 74 - 0
src/main/java/com/szwl/model/utils/Constant.java

@@ -0,0 +1,74 @@
+package com.szwl.model.utils;
+
+/**
+ * Created by dinfeng 
+ */
+public class Constant {
+
+    private static double EARTH_RADIUS = 6371.393;
+    private static double rad(double d)
+    {
+        return d * Math.PI / 180.0;
+    }
+
+    /**
+     * 计算两个经纬度之间的距离
+     * @param lat1
+     * @param lng1
+     * @param lat2
+     * @param lng2
+     * @return
+     */
+    public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
+    {
+        double radLat1 = rad(lat1);
+        double radLat2 = rad(lat2);
+        double a = radLat1 - radLat2;
+        double b = rad(lng1) - rad(lng2);
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
+                Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
+        s = s * EARTH_RADIUS;
+        s = Math.round(s * 1000);
+        return s;
+    }
+
+    /**
+     * admin 默认role id 1
+     */
+    public final static Long ROLE_ID_ADMIN = 1l;
+
+    /**
+     * 代理商 默认role id 2
+     */
+    public final static Long ROLE_ID_AGENCY= 2l;
+
+    /**
+     * 经销商 默认role id 3
+     */
+    public final static Long ROLE_ID_MERCHANT= 3l;
+
+    /**
+     * 个人商家 默认role id 4
+     */
+    public final static Long ROLE_ID_PERSONAGE= 4l;
+
+    /**
+     * 正确结果
+     */
+    public final static String correct_code = "ok";
+
+    /**
+     *
+     *
+     *
+     *      GlobalConfig
+     *
+     *
+     *
+     */
+
+    /**
+     * admin 访问码
+     */
+    public final static String ACCESS_CODE = "8";
+}

+ 266 - 0
src/main/java/com/szwl/model/utils/DateUtils.java

@@ -0,0 +1,266 @@
+package com.szwl.model.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DateUtils
+{
+  public static final String PATTERN_MMdd = "MMdd";
+  public static final String PATTERN_yyyyMMdd = "yyyyMMdd";
+  public static final String PATTERN_yyyyMMddHHmmss = "yyyyMMddHHmmss";
+  public static final String PATTERN_yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
+  public static final String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
+  public static final String PATTERN_yyyy_M_d = "yyyy-M-d";
+  public static final String PATTERN_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
+  public static final String PATTERN_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
+  public static final String PATTERN_HH_mm_ss = "HH:mm:ss";
+  public static final String PATTERN_HHmmss = "HHmmss";
+  public static final String PATTERN_HH = "HH";
+  public static final String PATTERN_MMdd2 = "MM月dd";
+  public static final String PATTERN_MM = "MM";
+  public static final Map<String, String> mapChDate = new HashMap<String, String>();
+
+  public static Date getNextday(Date now)
+  {
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTime(now);
+    calendar.add(5, 1);
+    return calendar.getTime();
+  }
+  
+  public static Date getPreday(Date now)
+  {
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTime(now);
+    calendar.add(5, -1);
+    return calendar.getTime();
+  }
+
+  public static String formatDate_ch(Date date)
+  {
+    if(date==null){
+   	 throw new IllegalArgumentException("需要转换的对象为空");
+    }
+    String str = formatDate(date, "MMdd");
+    str = (String)mapChDate.get(str.substring(0, 2)) + str.substring(2);
+    return str;
+  }
+
+  public static String formatDate(Date date, String pattern)
+  {
+    if(date==null){
+        return "";
+    }
+    SimpleDateFormat sdf = null;
+    if (pattern == null)
+      sdf = new SimpleDateFormat();
+    else {
+      sdf = new SimpleDateFormat(pattern);
+    }
+    return sdf.format(date);
+  }
+
+  public static String formatDate(Date date) {
+    SimpleDateFormat sdf = new SimpleDateFormat();
+    return sdf.format(date);
+  }
+
+  public static Date parseDate(String source, String pattern) throws ParseException
+  {
+    SimpleDateFormat sdf = null;
+    if (pattern == null)
+      sdf = new SimpleDateFormat();
+    else {
+      sdf = new SimpleDateFormat(pattern);
+    }
+    return sdf.parse(source);
+  }
+
+  public static Date parseDate(String source) throws ParseException {
+    SimpleDateFormat sdf = new SimpleDateFormat();
+    return sdf.parse(source);
+  }
+
+  public static Date parseDate(String source, Date defaultDate) {
+    try {
+      SimpleDateFormat sdf = new SimpleDateFormat();
+      return sdf.parse(source);
+    }
+    catch (ParseException e)
+    {
+    }
+    return defaultDate;
+  }
+
+  public static Date parseDate(String source, String pattern, Date defaultDate) {
+    try {
+      SimpleDateFormat sdf = null;
+      if (pattern == null)
+        sdf = new SimpleDateFormat();
+      else {
+        sdf = new SimpleDateFormat(pattern);
+      }
+      return sdf.parse(source);
+    }
+    catch (ParseException e) {
+    }
+    return defaultDate;
+  }
+
+  public static boolean tryParse(String source) throws ParseException {
+    try {
+      Integer.parseInt(source);
+      return true;
+    } catch (NumberFormatException e) {
+    }
+    return false;
+  }
+
+  public static Date changeDate(Date date, TimeType timeType, int amount)
+  {
+    if ((date == null) || (timeType == null) || (amount == 0)) {
+      return date;
+    }
+    Calendar c = Calendar.getInstance();
+    c.setTime(date);
+    c.add(timeType.getValue(), amount);
+    return c.getTime();
+  }
+
+  public static boolean isSameDay(Date date1, Date date2)
+  {
+    if ((date1 == null) || (date2 == null)) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    Calendar cal1 = Calendar.getInstance();
+    cal1.setTime(date1);
+    Calendar cal2 = Calendar.getInstance();
+    cal2.setTime(date2);
+    return isSameDay(cal1, cal2);
+  }
+
+  public static boolean isSameDay(Calendar cal1, Calendar cal2)
+  {
+    if ((cal1 == null) || (cal2 == null)) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    return (cal1.get(0) == cal2.get(0)) && (cal1.get(1) == cal2.get(1)) && (cal1.get(6) == cal2.get(6));
+  }
+
+  /** @deprecated */
+  public static Date add(Date date, int calendarField, int amount)
+  {
+    if (date == null) {
+      throw new IllegalArgumentException("The date must not be null");
+    }
+    Calendar c = Calendar.getInstance();
+    c.setTime(date);
+    c.add(calendarField, amount);
+    return c.getTime();
+  }
+
+  public static Date addYears(Date date, int amount)
+  {
+    return add(date, 1, amount);
+  }
+
+  public static Date addMonths(Date date, int amount)
+  {
+    return add(date, 2, amount);
+  }
+
+  public static Date addWeeks(Date date, int amount)
+  {
+    return add(date, 3, amount);
+  }
+
+  public static Date addDays(Date date, int amount)
+  {
+    return add(date, 5, amount);
+  }
+
+  public static Date addHours(Date date, int amount)
+  {
+    return add(date, 11, amount);
+  }
+
+  public static Date addMinutes(Date date, int amount)
+  {
+    return add(date, 12, amount);
+  }
+
+  public static Date addSeconds(Date date, int amount)
+  {
+    return add(date, 13, amount);
+  }
+
+  public static Date addMilliseconds(Date date, int amount)
+  {
+    return add(date, 14, amount);
+  }
+
+  static
+  {
+    mapChDate.put("01", "一月");
+    mapChDate.put("02", "二月");
+    mapChDate.put("03", "三月");
+    mapChDate.put("04", "四月");
+    mapChDate.put("05", "五月");
+    mapChDate.put("06", "六月");
+    mapChDate.put("07", "七月");
+    mapChDate.put("08", "八月");
+    mapChDate.put("09", "九月");
+    mapChDate.put("10", "十月");
+    mapChDate.put("11", "十一月");
+    mapChDate.put("12", "十二月");
+  }
+
+  public static enum TimeType
+  {
+    SECOND(13), MINUTE(12), HOUR(10), DAY(5), 
+    WEEK(4), MONTH(2), 
+    YEAR(1);
+
+    private int value;
+
+    private TimeType(int value) {
+      this.value = value;
+    }
+
+    public int getValue() {
+      return this.value;
+    }
+  }
+  /**
+   * 
+   * 毛龙飞
+   * @Description 获取日期的后几天
+   * @param d
+   * @param day
+   * @return
+   */
+  public static Date getDateAfter(Date d, int day) {  
+      Calendar now = Calendar.getInstance();  
+      now.setTime(d);  
+      now.set(Calendar.DATE, now.get(Calendar.DATE) + day);  
+      return now.getTime();  
+  }
+
+  /**
+   * 获取week 0是周日
+   * @param day
+   * @return
+   */
+  public static int getWeek(Date day) {
+    Calendar cal = Calendar.getInstance();
+    cal.setTime(day);
+    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+    if (w < 0)
+      w = 0;
+    return w;
+  }
+}

+ 489 - 0
src/main/java/com/szwl/model/utils/FgObjectUtil.java

@@ -0,0 +1,489 @@
+package com.szwl.model.utils;
+
+import com.szwl.model.bo.ParamNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * 
+ * 类说明:对象操作  
+ * @author 吴洪双
+ * 2016年1月13日上午10:57:51
+ */
+public class FgObjectUtil implements Serializable{
+	
+	private static final long serialVersionUID = 455370045995076257L;
+	
+	private static Logger logger = LoggerFactory.getLogger(FgObjectUtil.class);
+	/**
+	 * 递归获取所有父类的属性
+	 * @return
+	 */
+	public static ArrayList<Field> getAllFields(Class<?> object,ArrayList<Field> fieldList){
+		Class<?> supperClass = object.getSuperclass();
+		if(supperClass!=null){
+			Field[] fields = supperClass.getDeclaredFields();
+			for (Field field : fields) {
+				fieldList.add(field);
+			}
+			
+			return getAllFields(supperClass,fieldList);
+		}else{
+			return fieldList;
+		}
+	}
+	/**
+	 * 递归获取所有父类的方法
+	 * @return
+	 */
+	public static ArrayList<Method> getAllMethods(Class<?> object,ArrayList<Method> methodList){
+		Class<?> supperClass = object.getSuperclass();
+		if(supperClass!=null){
+			
+			Method[] methods = supperClass.getMethods();
+			for (Method method : methods) {
+				methodList.add(method);
+			}
+			
+			return getAllMethods(supperClass,methodList);
+		}else{
+			return methodList;
+		}
+	}
+	
+	/**
+	 * 
+	 * 方法说明:对象非空校验
+	 * @author 吴洪双
+	 * 2016年1月13日下午4:52:04
+	 * @param object
+	 * @throws NoSuchMethodException
+	 * @throws SecurityException
+	 * @throws Exception
+	 * @throws ParamNotFoundException
+	 */
+	public static void objectNullOrEmpty(Object object) throws ParamNotFoundException {
+		if (object != null ) {// if (object!=null
+			try{
+				// 拿到该类
+				Class<?> clz = object.getClass();
+				// 获取实体类的所有属性,返回Field数组
+				Field[] fields = clz.getDeclaredFields();
+				ArrayList<Field> fieldList= new ArrayList<Field>();
+				for (Field field : fields) {
+					fieldList.add(field);
+				}
+				//获取实体类所有父类的属性
+				fieldList = getAllFields(clz,fieldList);
+				
+				for (Field field : fieldList) {// --for() begin
+					if("serialVersionUID".equals(field.getName())){
+						continue;
+					}
+					// 如果类型是String
+					if (field.getGenericType().toString().equals("class java.lang.String")) { // 如果type是类类型,则前面包含"class ",后面跟类名
+						// 拿到该属性的gettet方法
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						String val = (String) m.invoke(object);// 调用getter方法获取属性值
+						if(val==null || val.length() == 0){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Date
+					if (field.getGenericType().toString().equals("class java.util.Date")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Date val = (Date) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Integer
+					if (field.getGenericType().toString().equals("class java.lang.Integer")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Integer val = (Integer) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Double
+					if (field.getGenericType().toString().equals("class java.lang.Double")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Double val = (Double) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Boolean 是封装类
+					if (field.getGenericType().toString().equals("class java.lang.Boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是boolean 基本数据类型不一样 这里有点说名如果定义名是 isXXX的 那就全都是isXXX的
+					// 反射找不到getter的具体名
+					if (field.getGenericType().toString().equals("boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Short
+					if (field.getGenericType().toString().equals("class java.lang.Short")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Short val = (Short) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//如果是枚举类型
+					if(field.getGenericType().toString().contains(".bean.enums.")){
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						if(m.invoke(object) == null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//其他类型
+					Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+					if(m.invoke(object) == null){
+						logger.debug(field.getName()+"is null");
+						throw new ParamNotFoundException(field.getName());
+					}
+				}
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			} catch (SecurityException e) {
+				e.printStackTrace();
+			} catch (ParamNotFoundException e) {
+				throw e;
+			} catch (Exception e){
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	/**
+	 * 
+	 * 方法说明:非包含的参数校验
+	 * @author 吴洪双
+	 * 2016年1月13日下午5:27:15
+	 * @param object
+	 * @param del
+	 * @throws NoSuchMethodException
+	 * @throws SecurityException
+	 * @throws Exception
+	 * @throws ParamNotFoundException
+	 */
+	public static void objectNullOrEmptyDel(Object object,String del) throws ParamNotFoundException{
+		if (object != null ) {// if (object!=null
+			try{
+				// 拿到该类
+				Class<?> clz = object.getClass();
+				// 获取实体类的所有属性,返回Field数组
+				Field[] fields = clz.getDeclaredFields();
+				ArrayList<Field> fieldList= new ArrayList<Field>();
+				for (Field field : fields) {
+					fieldList.add(field);
+				}
+				//获取实体类所有父类的属性
+				fieldList = getAllFields(clz,fieldList);
+				
+				for (Field field : fieldList) {// --for() begin
+					if(del.contains(field.getName()+"$") || "serialVersionUID".equals(field.getName())){
+						continue;
+					}
+					// 如果类型是String
+					if (field.getGenericType().toString().equals("class java.lang.String")) { // 如果type是类类型,则前面包含"class ",后面跟类名
+						// 拿到该属性的gettet方法
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						String val = (String) m.invoke(object);// 调用getter方法获取属性值
+						if(val==null || val.length() == 0){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Date
+					if (field.getGenericType().toString().equals("class java.util.Date")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Date val = (Date) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Integer
+					if (field.getGenericType().toString().equals("class java.lang.Integer")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Integer val = (Integer) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Double
+					if (field.getGenericType().toString().equals("class java.lang.Double")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Double val = (Double) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Boolean 是封装类
+					if (field.getGenericType().toString().equals("class java.lang.Boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是boolean 基本数据类型不一样 这里有点说名如果定义名是 isXXX的 那就全都是isXXX的
+					// 反射找不到getter的具体名
+					if (field.getGenericType().toString().equals("boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Short
+					if (field.getGenericType().toString().equals("class java.lang.Short")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Short val = (Short) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//如果是枚举类型
+					if(field.getGenericType().toString().contains(".bean.enums.")){
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						if(m.invoke(object) == null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//其他类型
+					Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+					if(m.invoke(object) == null){
+						logger.debug(field.getName()+"is null");
+						throw new ParamNotFoundException(field.getName());
+					}
+				}
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			} catch (SecurityException e) {
+				e.printStackTrace();
+			} catch (ParamNotFoundException e) {
+				throw e;
+			} catch (Exception e){
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	/**
+	 * 
+	 * 方法说明:包含的参数校验
+	 * @author 吴洪双
+	 * 2016年1月13日下午5:26:41
+	 * @param object
+	 * @param sel
+	 * @throws NoSuchMethodException
+	 * @throws SecurityException
+	 * @throws Exception
+	 * @throws ParamNotFoundException
+	 */
+	public static void objectNullOrEmptySel(Object object,String sel) throws ParamNotFoundException{
+		if (object != null ) {// if (object!=null
+			try{
+				// 拿到该类
+				Class<?> clz = object.getClass();
+				// 获取实体类的所有属性,返回Field数组
+				Field[] fields = clz.getDeclaredFields();
+				ArrayList<Field> fieldList= new ArrayList<Field>();
+				for (Field field : fields) {
+					fieldList.add(field);
+				}
+				//获取实体类所有父类的属性
+				fieldList = getAllFields(clz,fieldList);
+				
+				for (Field field : fieldList) {// --for() begin
+					if(!sel.contains(field.getName()+"$") || "serialVersionUID".equals(field.getName())){
+						continue;
+					}
+					// 如果类型是String
+					if (field.getGenericType().toString().equals("class java.lang.String")) { // 如果type是类类型,则前面包含"class ",后面跟类名
+						// 拿到该属性的gettet方法
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						String val = (String) m.invoke(object);// 调用getter方法获取属性值
+						if(val==null || val.length() == 0){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Date
+					if (field.getGenericType().toString().equals("class java.util.Date")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Date val = (Date) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Integer
+					if (field.getGenericType().toString().equals("class java.lang.Integer")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Integer val = (Integer) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Double
+					if (field.getGenericType().toString().equals("class java.lang.Double")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Double val = (Double) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Boolean 是封装类
+					if (field.getGenericType().toString().equals("class java.lang.Boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+" is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是boolean 基本数据类型不一样 这里有点说名如果定义名是 isXXX的 那就全都是isXXX的
+					// 反射找不到getter的具体名
+					if (field.getGenericType().toString().equals("boolean")) {
+						Method m = (Method) object.getClass().getMethod(field.getName());
+						Boolean val = (Boolean) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					// 如果类型是Short
+					if (field.getGenericType().toString().equals("class java.lang.Short")) {
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						Short val = (Short) m.invoke(object);
+						if(val==null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//如果是枚举类型
+					if(field.getGenericType().toString().contains(".bean.enums.")){
+						Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+						if(m.invoke(object) == null){
+							logger.debug(field.getName()+"is null");
+							throw new ParamNotFoundException(field.getName());
+						}
+						continue;
+					}
+					//其他类型
+					Method m = (Method) object.getClass().getMethod("get" + getMethodName(field.getName()));
+					if(m.invoke(object) == null){
+						logger.debug(field.getName()+"is null");
+						throw new ParamNotFoundException(field.getName());
+					}
+				}
+			} catch (NoSuchMethodException e) {
+				e.printStackTrace();
+			} catch (SecurityException e) {
+				e.printStackTrace();
+			} catch (ParamNotFoundException e) {
+				throw e;
+			} catch (Exception e){
+				e.printStackTrace();
+			}
+		}
+		
+	}
+	
+	/**
+	 * 
+	 * 方法说明:返回方法名称   把一个字符串的第一个字母大写、效率是最高的、
+	 * @author 吴洪双
+	 * 2016年1月13日上午11:12:41
+	 * @param fildeName
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getMethodName(String fildeName) throws Exception {
+		byte[] items = fildeName.getBytes();
+		items[0] = (byte) ((char) items[0] - 'a' + 'A');
+		return new String(items);
+	}
+
+	public static Class getPropertyType(Object property) {
+		if(property instanceof String) {
+			return String.class;
+		}
+		else if(property instanceof Integer) {
+			return Integer.class;
+		}
+		else if(property instanceof Long) {
+			return Long.class;
+		}
+		else if(property instanceof Double) {
+			return Double.class;
+		}
+		else if(property instanceof Date) {
+			return Date.class;
+		}
+		else if(property instanceof Boolean) {
+			return Boolean.class;
+		}
+		else {
+			return String.class;
+		}
+	}
+}

+ 85 - 0
src/main/java/com/szwl/model/utils/HEXUtil.java

@@ -0,0 +1,85 @@
+package com.szwl.model.utils;
+
+import com.szwl.model.utils.constants.CommonConst;
+import com.szwl.model.utils.exceptions.JPException;
+
+/**
+ * 16进制工具类
+ * @author chenyf
+ * @date 2018-12-15
+ */
+public class HEXUtil {
+    private static final char[] DIGITS_LOWER =
+            {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    private static final char[] DIGITS_UPPER =
+            {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+
+    public static String encode(String str){
+        try{
+            return encode(str.getBytes(CommonConst.ENCODING_UTF_8), true);
+        }catch (Exception e){
+            throw new JPException("16进制转换失败", e);
+        }
+    }
+
+    public static String encode(byte[] data, final boolean toUpperCase){
+        return bytes2Hex(data, toUpperCase ? DIGITS_UPPER : DIGITS_LOWER);
+    }
+
+    public static String decode(String str){
+        try{
+            byte[] date = hex2Bytes(str);
+            return new String(date, CommonConst.ENCODING_UTF_8);
+        }catch (Exception e){
+            throw new JPException("16进制转换失败", e);
+        }
+    }
+
+    private static String bytes2Hex(final byte[] data, final char[] toDigits) {
+        final int l = data.length;
+        final char[] out = new char[l << 1];
+        // two characters form the hex value.
+        for (int i = 0, j = 0; i < l; i++) {
+            out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
+            out[j++] = toDigits[0x0F & data[i]];
+        }
+        return new String(out);
+    }
+
+    private static byte[] hex2Bytes(final String data) throws Exception {
+        final int len = data.length();
+
+        if ((len & 0x01) != 0) {
+            throw new Exception("Odd number of characters.");
+        }
+
+        final byte[] out = new byte[len >> 1];
+
+        // two characters form the hex value.
+        for (int i = 0, j = 0; j < len; i++) {
+            int f = toDigit(data.charAt(j), j) << 4;
+            j++;
+            f = f | toDigit(data.charAt(j), j);
+            j++;
+            out[i] = (byte) (f & 0xFF);
+        }
+        return out;
+    }
+
+    /**
+     * 16转化为数字
+     * @param ch 16进制
+     * @param index 索引
+     * @return 转化结果
+     * @throws Exception 转化失败异常
+     */
+    private static int toDigit(final char ch, final int index) throws Exception {
+        final int digit = Character.digit(ch, 16);
+        if (digit == -1) {
+            throw new Exception("Illegal hexadecimal character " + ch + " at index " + index);
+        }
+        return digit;
+    }
+}

+ 332 - 0
src/main/java/com/szwl/model/utils/HttpClientUtils.java

@@ -0,0 +1,332 @@
+package com.szwl.model.utils;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by study on 6/26/2015 11:30.
+ */
+public final class HttpClientUtils {
+    private static Logger logger = Logger.getLogger("HttpClientUtils");
+    public final static String Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
+    public final static String Update_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateOrder";
+//    public final static String Es_Order_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getOrder";
+    public final static String CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
+//    public final static String Es_CoinOrder_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getCoinOrder";
+public final static String Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/getEquipment";
+    public final static String Update_Equipment_Url = "http://app.sunzee.com.cn/ShenzeeServer/EsApi/updateEquipment";
+    private HttpClientUtils() {
+    }
+
+    /**
+     * post xml
+     *
+     * @param url
+     * @param xml
+     * @return
+     */
+    public static String postXml(String url, String xml) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpPost post = new HttpPost(url);
+        String response = null;
+        InputStream instream = null;
+        try {
+            StringEntity s = new StringEntity(xml, "UTF-8");
+            s.setContentEncoding("UTF-8");
+            s.setContentType("application/xml");
+            post.setEntity(s);
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(post);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                SAXReader reader = new SAXReader();
+                instream = entity.getContent();
+                Document document = reader.read(new InputStreamReader(instream, "utf-8"));
+                response = document.asXML();
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+    /**
+     * post json
+     *
+     * @param url
+     * @param json
+     * @return
+     */
+    public static JSONObject postJson(String url, String json) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpPost post = new HttpPost(url);
+        JSONObject response = null;
+        InputStream instream = null;
+        try {
+            StringEntity s = new StringEntity(json, "UTF-8");
+            s.setContentEncoding("UTF-8");
+            s.setContentType("application/json");
+            post.setEntity(s);
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(post);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                String charset = "utf-8";
+                instream = entity.getContent();
+                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, charset)));
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+
+    /**
+     * java httpClient4.5 post请求
+     */
+    @SuppressWarnings("unchecked")
+    public static String sendPost(String sendMsg, String sendUrl) {
+        HttpPost httpPost = new HttpPost(sendUrl);
+        HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+        CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
+        StringEntity entity;
+        String status = "false";
+        Map<String,Object> mres = new HashMap<String, Object>();
+        try {
+            entity = new StringEntity(sendMsg, "UTF-8"); //解决参数中文乱码问题
+            entity.setContentEncoding("UTF-8");//设置编码格式
+            entity.setContentType("application/json");
+            httpPost.setEntity(entity);
+            // 发起请求
+            HttpResponse httpResponse = closeableHttpClient.execute(httpPost);
+            // 请求结束,返回结果。并解析json。
+            String resData = EntityUtils.toString(httpResponse.getEntity(),"UTF-8");
+            status = resData;
+//            Map map = JSON.parseObject(JSON.toJSONString(resData), Map.class);
+//            mres = (Map<String, Object>) JSON.parseObject(JSON.toJSONString(resData), Map.class);
+//            mres = (Map<String, Object>) JSONObject.toBean(JSONObject.fromObject(resData), Map.class);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (null != closeableHttpClient) {
+                try {
+                    closeableHttpClient.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return status;
+//        return mres;
+    }
+    /**
+     * post 键值对
+     *
+     * @param url
+     * @param data 键值对内容
+     * @return
+     */
+    public static String sentData(String url, String data) {
+        if(!StringUtils.isEmpty(url)&&!StringUtils.isEmpty(data)){
+            String result = sendPost(data, url);
+            return result;
+        }
+        return "400";
+    }
+
+    /**
+     * post 键值对
+     *
+     * @param url
+     * @param data 键值对内容
+     * @return
+     */
+    public static String postKeyValue(String url, List<BasicNameValuePair> data) {
+
+
+        CloseableHttpClient httpClient = getHttpClient();
+        try {
+            HttpPost post = new HttpPost(url);
+
+
+            //url格式编码
+            UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(data, "UTF-8");
+            post.setEntity(uefEntity);
+            CloseableHttpResponse httpResponse = httpClient.execute(post);
+            HttpEntity entity = httpResponse.getEntity();
+            try {
+                if (null != entity) {
+                    String result = EntityUtils.toString(entity);
+                    return result;
+                }
+            } finally {
+                httpResponse.close();
+            }
+
+
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                closeHttpClient(httpClient);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * get json
+     *
+     * @param url
+     * @return
+     */
+    public static JSONObject get(String url) throws IOException {
+        HttpClient client = HttpClientBuilder.create().build();
+        client = WebClientDevWrapper.wrapClient(client);
+        HttpGet get = new HttpGet(url);
+        JSONObject response = null;
+        InputStream instream = null;
+        try {
+            HttpResponse res = null;
+            if (client != null) {
+                res = client.execute(get);
+            }
+            if (res != null && res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = res.getEntity();
+                instream = entity.getContent();
+                response = new JSONObject(new JSONTokener(new InputStreamReader(instream, "utf-8")));
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (instream != null) {
+                instream.close();
+            }
+        }
+        return response;
+    }
+
+    private static class WebClientDevWrapper {
+        public static HttpClient wrapClient(HttpClient base) {
+            try {
+                RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.create();
+                ConnectionSocketFactory plainSF = new PlainConnectionSocketFactory();
+                registryBuilder.register("http", plainSF);
+                //指定信任密钥存储对象和连接套接字工厂
+                try {
+                    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+                    SSLContext sslContext = SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, new AnyTrustStrategy()).build();
+                    LayeredConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+                    registryBuilder.register("https", sslSF);
+                } catch (KeyStoreException e) {
+                    throw new RuntimeException(e);
+                } catch (KeyManagementException e) {
+                    throw new RuntimeException(e);
+                } catch (NoSuchAlgorithmException e) {
+                    throw new RuntimeException(e);
+                }
+                Registry<ConnectionSocketFactory> registry = registryBuilder.build();
+                //设置连接管理器
+                PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry);
+                connManager.setDefaultConnectionConfig(ConnectionConfig.custom().setCharset(Charset.forName("UTF-8")).build());
+                connManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(100000).build());
+                //构建客户端
+                return HttpClientBuilder.create().setConnectionManager(connManager).build();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            return null;
+        }
+
+        private static class AnyTrustStrategy implements TrustStrategy {
+            @Override
+            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+                return true;
+            }
+        }
+
+
+    }
+
+
+    private static CloseableHttpClient getHttpClient() {
+        return HttpClients.createDefault();
+    }
+
+    private static void closeHttpClient(CloseableHttpClient client) throws IOException {
+        if (client != null) {
+            client.close();
+        }
+    }
+
+}

+ 269 - 0
src/main/java/com/szwl/model/utils/JoinpayConstant.java

@@ -0,0 +1,269 @@
+package com.szwl.model.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 汇聚支付 常量
+ */
+public class JoinpayConstant {
+
+
+    /**
+     * 商户编码
+     */
+    public final static String mch_no = "888106600000003";
+
+
+    /**
+     * 商户密钥 : MD5
+     */
+    public final static String key = "8cb1d25eba7d4f3caecf1f0569150e04";
+
+
+    /**
+     * 汇聚公钥
+     */
+    public final static String publickey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCLgawJlQ3O8/O9YmJt6mi0pzh9JiDGp2G6IW3p8NTZXE5tIBZRbQAkHnr/zaLh0kDHMtIGAcGUtgXilRxXeUIuc0/j561YLsxAORma2XerniRCLWrXS4yM8F1/813Rv21JoNFkDZWHdTgEpKTH8GaGYOHiEytIN0LvPzEvNsimWQIDAQAB";
+
+    /**
+     * >>>>>>>>>>>>> 币种 >>>>>>>>>>>>>
+     *
+     */
+    /**
+     * 人民币
+     */
+    public final static String Cur_RMB = "1";
+
+
+    /**
+     *  支付成功回调
+     */
+    public final static String Notify_Url = "http://app.sunzee.com.cn/api/order/notify.htm";
+//    public final static String Notify_Url = "http://slb.sunzee.com.cn/api/order/notify.htm";
+
+    public final static String mg280Notify_Url = "http://app.sunzee.com.cn/api/order/mg280Notify.htm";
+//    public final static String mg280Notify_Url = "http://slb.sunzee.com.cn/api/order/mg280Notify.htm";
+
+    public final static String Notify_Url_PromoCode = "http://app.sunzee.com.cn/api/order/promoCodeNotify.htm";
+//    public final static String Notify_Url_PromoCode = "http://slb.sunzee.com.cn/api/order/promoCodeNotify.htm";
+
+    public final static String Jiesuan_Url = "http://app.sunzee.com.cn/api/order/jiesuan.htm";
+//    public final static String Jiesuan_Url = "http://slb.sunzee.com.cn/api/order/jiesuan.htm";
+
+    public final static Map<String,String> Result_status = new HashMap<>();
+    /**
+     *  退款成功回调
+     */
+    public final static String Notify_Refund_Url = "http://app.sunzee.com.cn/api/order/notifyRefund.htm";
+    public final static String Admin_Notify_Refund_Url = "http://app.sunzee.com.cn/api/order/adminNotifyRefund.htm";
+
+
+    /**
+     * 支付回调支付状态代码
+     */
+    public final static String r6_Status_100 = "100";
+    public final static String r6_Status_101 = "101";
+
+    /**
+     * >>>>>>>>>>>>> 签名类型 >>>>>>>>>>>>>
+     * 1=MD5,2=RSA
+     */
+    public final static String sign_type_MD5 = "1";
+    public final static String sign_type_RSA = "2";
+
+
+    /**
+     * >>>>>>>>>>>>> 分账方商户类型 >>>>>>>>>>>>>
+     * 10:个人,11:个体工商户,12:企业
+     */
+    public final static Integer alt_merchant_type1 = 10;
+    public final static Integer alt_merchant_type2 = 11;
+    public final static Integer alt_merchant_type3 = 12;
+
+    /**
+     * >>>>>>>>>>>>> 分账方结算方式 >>>>>>>>>>>>>
+     * 1 由汇聚自动结算
+     * 2 由商户平台手工结算(结算接口)
+     */
+    public final static Integer sett_mode1 = 1;
+    public final static Integer sett_mode2 = 2;
+
+
+    /**
+     * >>>>>>>>>>>>> 结算周期类型 >>>>>>>>>>>>>
+     * 1 工作日,2 自然日,3 月结日
+     */
+    public final static Integer sett_date_type1 = 1;
+    public final static Integer sett_date_type2 = 2;
+    public final static Integer sett_date_type3 = 3;
+
+
+    /**
+     * >>>>>>>>>>>>> 账户类型 >>>>>>>>>>>>>
+     * 1 借记卡,4 对公账户
+     */
+    public final static Integer bank_account_type1 = 1;
+    public final static Integer bank_account_type4 = 4;
+
+
+    /**
+     *
+     *
+     *  >>>>>>>>>>>>> 响应码 >>>>>>>>>>>>>
+     *
+     *
+     */
+
+    /**
+     * 受理响应码
+     */
+    public static final Map<String, String> resp_code = new HashMap<>();
+    public static final String resp_code1 = "A1000";
+    public static final String resp_code2 = "A2000";
+    public static final String resp_code3 = "A3000";
+
+    static {
+        resp_code.put(resp_code1, "受理成功");
+        resp_code.put(resp_code2, "受理失败,具体失败原因查看业务响应码");
+        resp_code.put(resp_code3, "受理未知(如:接口调用超时)");
+    }
+
+    /**
+     * 商户状态
+     */
+    public static final Map<String, String> order_status = new HashMap<>();
+    public static final String order_status1 = "P0001";
+    public static final String order_status2 = "P1000";
+    public static final String order_status3 = "P2000";
+    public static final String order_status4 = "P3000";
+    public static final String order_status5 = "P3001";
+    public static final String order_status6 = "P3002";
+    public static final String order_status7 = "P3003";
+
+    static {
+        order_status.put(order_status1, "待处理中(受理中)");
+        order_status.put(order_status2, "交易成功");
+        order_status.put(order_status3, "交易失败");
+        order_status.put(order_status4, "结果未知");
+        order_status.put(order_status5, "处理中");
+        order_status.put(order_status6, "激活");
+        order_status.put(order_status7, "冻结");
+    }
+
+    /**
+     * 业务响应码
+     */
+    public static final Map<String, String> biz_code = new HashMap<>();
+    public static final String biz_code1 = "B100000";
+    public static final String biz_code2 = "B100001";
+    public static final String biz_code3 = "B100002";
+    public static final String biz_code4 = "B100003";
+    public static final String biz_code5 = "B101001";
+    public static final String biz_code6 = "B101002";
+    public static final String biz_code7 = "B101003";
+    public static final String biz_code8 = "B101004";
+    public static final String biz_code9 = "B101005";
+    public static final String biz_code10 = "B103012";
+    public static final String biz_code11 = "B103013";
+    public static final String biz_code12 = "B102001";
+
+    static {
+        biz_code.put(biz_code1, "受理成功");
+        biz_code.put(biz_code2, "验签失败");
+        biz_code.put(biz_code3, "验参失败");
+        biz_code.put(biz_code4, "结果未知,SYS_ERROR");
+        biz_code.put(biz_code5, "登录名已存在");
+        biz_code.put(biz_code6, "找不到卡bin");
+        biz_code.put(biz_code7, "联行号有误");
+        biz_code.put(biz_code8, "查找不到银行信息");
+        biz_code.put(biz_code9, "不支持的结算卡类型");
+        biz_code.put(biz_code10, "担保账户不存在");
+        biz_code.put(biz_code11, "担保账户余额不足");
+        biz_code.put(biz_code12, "分账方不存在");
+    }
+
+
+    /**
+     * >>>>>>>>>>>>> 支付交易类型 >>>>>>>>>>>>>
+     */
+    public static final Map<String, String> frp_code = new HashMap<>();
+    public static final String frp_code_ALIPAY_NATIVE = "ALIPAY_NATIVE";
+    public static final String frp_code_ALIPAY_CARD = "ALIPAY_CARD";
+    public static final String frp_code_ALIPAY_APP = "ALIPAY_APP";
+    public static final String frp_code_ALIPAY_H5 = "ALIPAY_H5";
+    public static final String frp_code_ALIPAY_FWC = "ALIPAY_FWC";
+    public static final String frp_code_ALIPAY_SYT = "ALIPAY_SYT";
+    public static final String frp_code_WEIXIN_NATIVE = "WEIXIN_NATIVE";
+    public static final String frp_code_WEIXIN_CARD = "WEIXIN_CARD";
+    public static final String frp_code_WEIXIN_APP = "WEIXIN_APP";
+    public static final String frp_code_WEIXIN_APP2 = "WEIXIN_APP2";
+    public static final String frp_code_WEIXIN_H5 = "WEIXIN_H5";
+    public static final String frp_code_WEIXIN_GZH = "WEIXIN_GZH";
+    public static final String frp_code_WEIXIN_XCX = "WEIXIN_XCX";
+    public static final String frp_code_JD_NATIVE = "JD_NATIVE";
+    public static final String frp_code_JD_CARD = "JD_CARD";
+    public static final String frp_code_JD_APP = "JD_APP";
+    public static final String frp_code_JD_H5 = "JD_H5";
+    public static final String frp_code_QQ_NATIVE = "QQ_NATIVE";
+    public static final String frp_code_QQ_CARD = "QQ_CARD";
+    public static final String frp_code_QQ_APP = "QQ_APP";
+    public static final String frp_code_QQ_H5 = "QQ_H5";
+    public static final String frp_code_QQ_GZH = "QQ_GZH";
+    public static final String frp_code_UNIONPAY_NATIVE = "UNIONPAY_NATIVE";
+    public static final String frp_code_UNIONPAY_CARD = "UNIONPAY_CARD";
+    public static final String frp_code_UNIONPAY_APP = "UNIONPAY_APP";
+    public static final String frp_code_UNIONPAY_H5 = "UNIONPAY_H5";
+    public static final String frp_code_BAIDU_NATIVE = "BAIDU_NATIVE";
+    public static final String frp_code_SUNING_NATIVE = "SUNING_NATIVE";
+
+
+    static {
+        biz_code.put(frp_code_ALIPAY_NATIVE, "支付宝扫码(主扫)");
+        biz_code.put(frp_code_ALIPAY_CARD, "支付宝刷卡(被扫)");
+        biz_code.put(frp_code_ALIPAY_APP, "支付宝APP 支付");
+        biz_code.put(frp_code_ALIPAY_H5, "支付宝H5");
+        biz_code.put(frp_code_ALIPAY_FWC, "支付宝服务窗");
+        biz_code.put(frp_code_ALIPAY_SYT, "支付宝收银台");
+        biz_code.put(frp_code_WEIXIN_NATIVE, "微信扫码(主扫)");
+        biz_code.put(frp_code_WEIXIN_CARD, "微信刷卡(被扫)");
+        biz_code.put(frp_code_WEIXIN_APP, "微信APP 支付");
+        biz_code.put(frp_code_WEIXIN_APP2, "微信APP2 支付");
+        biz_code.put(frp_code_WEIXIN_H5, "微信H5 支付");
+        biz_code.put(frp_code_WEIXIN_GZH, "微信公众号支付");
+        biz_code.put(frp_code_WEIXIN_XCX, "微信小程序支付");
+        biz_code.put(frp_code_JD_NATIVE, "京东扫码(主扫)");
+        biz_code.put(frp_code_JD_CARD, "京东刷卡(被扫)");
+        biz_code.put(frp_code_JD_APP, "京东APP 支付");
+        biz_code.put(frp_code_JD_H5, "京东H5 支付");
+        biz_code.put(frp_code_QQ_NATIVE, "QQ 扫码(主扫)");
+        biz_code.put(frp_code_QQ_CARD, "QQ 刷卡(被扫)");
+        biz_code.put(frp_code_QQ_APP, "QQ APP 支付");
+        biz_code.put(frp_code_QQ_H5, "QQH5 支付");
+        biz_code.put(frp_code_QQ_GZH, "QQ 公众号支付");
+        biz_code.put(frp_code_UNIONPAY_NATIVE, "银联扫码(主扫)");
+        biz_code.put(frp_code_UNIONPAY_CARD, "银联刷卡(被扫)");
+        biz_code.put(frp_code_UNIONPAY_APP, "银联APP 支付");
+        biz_code.put(frp_code_UNIONPAY_H5, "银联H5");
+        biz_code.put(frp_code_BAIDU_NATIVE, "百度扫码(主扫)");
+        biz_code.put(frp_code_SUNING_NATIVE, "苏宁扫码(主扫)");
+    }
+
+
+    /**
+     *
+     *
+     *  >>>>>>>>>>>>> 汇聚支付接口 >>>>>>>>>>>>>
+     *
+     *
+     */
+
+    /**
+     * 版本
+     */
+    public static final String pay_version = "1.0";
+
+
+
+
+}

+ 293 - 0
src/main/java/com/szwl/model/utils/PushUtils.java

@@ -0,0 +1,293 @@
+package com.szwl.model.utils;
+
+import com.gexin.rp.sdk.base.impl.SingleMessage;
+import com.gexin.rp.sdk.base.impl.Target;
+import com.gexin.rp.sdk.base.payload.APNPayload;
+import com.gexin.rp.sdk.exceptions.RequestException;
+import com.gexin.rp.sdk.http.IGtPush;
+import com.gexin.rp.sdk.template.TransmissionTemplate;
+import org.json.JSONObject;
+
+import java.util.List;
+
+/**
+ * Created by dinfeng on 2017/12/21
+ * 个推工具类
+ */
+public class PushUtils {
+
+
+    public final static String appId = "GKa6qa12heALjEXZlAn1U3";
+
+    public final static String appKey = "fLvPjR8hni7VFMkgjh8lx2";
+
+    public final static String masterSecret = "KjxrC6vTLr5wiZu55cCnS8";
+
+    public final static String host = "http://sdk.open.api.igexin.com/apiex.htm";
+
+//    public  static IPushResult rets =null;
+
+    public static String test_clientId = "c69869085580f3b77f2972403fbdd5b3";
+    public static String test_clientId2 = "200cb24ae7af3c4096cc2c46569ed530";
+
+
+    final static IGtPush push = new IGtPush(host, appKey, masterSecret);
+
+//    private static EquipmentService equipmentService;
+//
+//    @Autowired
+//    public PushUtils(EquipmentService equipmentService) {
+//        PushUtils.equipmentService = equipmentService;
+//    }
+//    private static RabbitTemplate rabbitTemplate;
+//
+//    @Autowired
+//    public PushUtils(RabbitTemplate rabbitTemplate) {
+//        PushUtils.rabbitTemplate = rabbitTemplate;
+//    }
+
+    /**
+     * 个推发送信息
+     *
+     * @param clientIds   设备号数组
+     * @param title
+     * @param information 信息
+     * @param json        业务id
+     */
+    public static void push(List<String> clientIds, String title, String information, String json) {
+
+
+        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+        //推送ios
+        final SingleMessage iMessage = new SingleMessage();
+        iMessage.setOffline(true);
+        // 离线有效时间,单位为毫秒,可选
+        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+        iMessage.setData(transmissionTemplate);
+        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+        iMessage.setPushNetWorkType(0);
+
+        //个推
+        for (String clientId : clientIds) {
+            final Target target = new Target();
+            target.setAppId(appId);
+            target.setClientId(clientId);
+
+            try {
+
+                new Thread(new Runnable() {
+//                    IPushResult ret = null;
+                    @Override
+                    public void run() {
+//                        ret = push.pushMessageToSingle(iMessage, target);
+                         push.pushMessageToSingle(iMessage, target);
+//                        rets = ret;
+                    }
+
+
+                }).start();
+
+            } catch (RequestException e) {
+                e.printStackTrace();
+                push.pushMessageToSingle(iMessage, target, e.getRequestId());
+            }
+        }
+    }
+
+
+    /**
+     * 个推发送信息
+     *
+     * @param clientId    设备号数组
+     * @param information 信息
+     * @param json        业务id
+     */
+    public static void push(String clientId, String title, String information, String json) {
+//        String type = "1";
+//        if(StringUtils.isNotEmpty(title)){
+//            type = title;
+//        }
+////        List<Filter> filters = new ArrayList<>();
+////        filters.add(Filter.eq("gtClientId", clientId));
+////        List<Equipment> list = equipmentService.findList(null, filters, null);
+////        if(list.size()>0){
+////            for(Equipment equipment:list){
+////                String channel = equipment.getChannel();
+////                String equimentType = equipment.getEquimentType();
+////                String client = equipment.getClientId();
+////                String substring = client.substring(client.length() - 1);
+////                if(substring.equals("x")){
+////                    break;
+////                }
+////                if(StringUtils.isEmpty(channel)||channel.equals("1")||StringUtils.isEmpty(equimentType)){
+////                    //用个推
+////                    type = "1";
+////                }
+////                if(channel.equals("2")||StringUtils.isNotEmpty(equimentType)){
+////                    //用mq
+////                    type = "2";
+////                    //1 创建消息
+////                    MessageProperties messageProperties = new MessageProperties();
+////                    messageProperties.setContentType("text/plain");
+////                    //设置消息的过期时间,60秒
+//////        messageProperties.setExpiration("60000");
+////                    Message message = new Message(json.getBytes(), messageProperties);
+////
+////                    rabbitTemplate.send(equimentType, client, message);
+////                }
+////            }
+////        }
+//        if(type.equals("2")){
+//            String[] split = information.split(":");
+//            String equimentType = split[0];
+//            String client = split[1];
+//            //1 创建消息
+//            MessageProperties messageProperties = new MessageProperties();
+//            messageProperties.setContentType("text/plain");
+//            //设置消息的过期时间,60秒
+////        messageProperties.setExpiration("60000");
+//            Message message = new Message(json.getBytes(), messageProperties);
+//            rabbitTemplate.convertAndSend(equimentType, client, message);
+////            rabbitTemplate.send(equimentType, client, message);
+//        }
+//
+//        if(type.equals("1")){
+//            TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+//            //推送ios
+//            final SingleMessage iMessage = new SingleMessage();
+//            iMessage.setOffline(true);
+//            // 离线有效时间,单位为毫秒,可选
+//            iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+//            iMessage.setData(transmissionTemplate);
+//            // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+//            iMessage.setPushNetWorkType(0);
+//
+//
+//            //个推
+//            final Target target = new Target();
+//            target.setAppId(appId);
+//            target.setClientId(clientId);
+//            try {
+//
+//                new Thread(new Runnable() {
+//
+//                    @Override
+//                    public void run() {
+//                        push.pushMessageToSingle(iMessage, target);
+//                    }
+//
+//
+//                }).start();
+//
+//            } catch (RequestException e) {
+//                e.printStackTrace();
+//                push.pushMessageToSingle(iMessage, target, e.getRequestId());
+//            }
+//        }
+        TransmissionTemplate transmissionTemplate = getTemplate(title, information, json);
+        //推送ios
+        final SingleMessage iMessage = new SingleMessage();
+        iMessage.setOffline(true);
+        // 离线有效时间,单位为毫秒,可选
+        iMessage.setOfflineExpireTime(24 * 3600 * 1000);
+        iMessage.setData(transmissionTemplate);
+        // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
+        iMessage.setPushNetWorkType(0);
+
+
+        //个推
+        final Target target = new Target();
+        target.setAppId(appId);
+        target.setClientId(clientId);
+        try {
+
+            new Thread(new Runnable() {
+
+                @Override
+                public void run() {
+                    push.pushMessageToSingle(iMessage, target);
+                }
+
+
+            }).start();
+
+        } catch (RequestException e) {
+            e.printStackTrace();
+            push.pushMessageToSingle(iMessage, target, e.getRequestId());
+        }
+    }
+
+    /**
+     * 苹果使用透传消息,通过设置payload信息,实现待机时的推送提醒;
+     * 对安卓来说就是没有payload的概念,所以需要去解析透传的消息,把title和body放在透传消息中
+     */
+    private static TransmissionTemplate getTemplate(String title, String msg, String json) {
+        title = title == null ? "" : title;
+        msg = msg == null ? "" : msg;
+        TransmissionTemplate template = new TransmissionTemplate();
+        template.setAppId(appId);
+        template.setAppkey(appKey);
+        template.setTransmissionContent(json);
+        template.setTransmissionType(2);
+        APNPayload payload = new APNPayload();
+        //在已有数字基础上加1显示,设置为-1时,在已有数字上减1显示,设置为数字时,显示指定数字
+        payload.setAutoBadge("+1");
+        payload.setContentAvailable(0);
+        payload.setSound("default");
+        payload.setCategory("$由客户端定义");
+        payload.addCustomMsg("payload",json);//好假
+
+        //字典模式使用APNPayload.DictionaryAlertMsg
+        //payload.setAlertMsg(getDictionaryAlertMsg(msg, title));
+
+        template.setAPNInfo(payload);
+        return template;
+    }
+
+    private static APNPayload.DictionaryAlertMsg getDictionaryAlertMsg(String msg, String title) {
+        APNPayload.DictionaryAlertMsg alertMsg = new APNPayload.DictionaryAlertMsg();
+        alertMsg.setBody(msg);//通知小内容
+        alertMsg.setActionLocKey("ActionLockey");
+        alertMsg.setLocKey("LocKey");
+        alertMsg.addLocArg("loc-args");
+        alertMsg.setLaunchImage("launch-image");
+
+        // iOS8.2以上版本支持
+        alertMsg.setTitle(title);//通知标题
+        alertMsg.setTitleLocKey("");
+        alertMsg.addTitleLocArg("");
+        return alertMsg;
+    }
+
+
+    public static JSONObject buildJson(String kind, String kindData) {
+        JSONObject jsonObject = new JSONObject();
+        if (kind != null) {
+            jsonObject.put("kind", kind);
+            jsonObject.put("kind_data", kindData);
+        }else{
+            jsonObject.put("kind", "");
+            jsonObject.put("kind_data", "");
+        }
+        return jsonObject;
+    }
+    public static JSONObject buildJson(String kind, String kindData,String netTime,String webTime) {
+        JSONObject jsonObject = new JSONObject();
+        if (kind != null) {
+            jsonObject.put("kind", kind);
+            jsonObject.put("kind_data", kindData);
+            jsonObject.put("netTime", netTime);
+            jsonObject.put("webTime", webTime);
+        }else{
+            jsonObject.put("kind", "");
+            jsonObject.put("kind_data", "");
+            jsonObject.put("netTime", "");
+            jsonObject.put("webTime", "");
+        }
+        return jsonObject;
+    }
+
+//    public static void main(String[] args) {
+//        push("71963777bd63e0f0a5b6490f04bf1ae4", "niai", "123", buildJson("editNo", "123456789").toString());
+//    }
+}

+ 187 - 0
src/main/java/com/szwl/model/utils/RSAUtil.java

@@ -0,0 +1,187 @@
+package com.szwl.model.utils;
+
+
+import com.szwl.model.utils.constants.Algorithm;
+import com.szwl.model.utils.constants.CommonConst;
+import com.szwl.model.utils.exceptions.JPException;
+
+import javax.crypto.Cipher;
+import java.io.ByteArrayOutputStream;
+import java.security.*;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * RSA加解密的工具类
+ * @author chenyf
+ * @date 2018-12-15
+ */
+public class RSAUtil {
+    public static final String DEFAULT_ENCRYPT_ALGORITHM = "RSA/ECB/PKCS1Padding";
+    public static final String SIGNATURE_ALGORITHM_SHA1 = "SHA1withRSA";
+    public static final String SIGNATURE_ALGORITHM_MD5 = "MD5withRSA";
+
+    public static final int KEY_SIZE = 1024;
+    public static final String PUBLIC_KEY = "publicKey";
+    public static final String PRIVATE_KEY = "privateKey";
+
+
+    /**
+    /**
+     * RSA最大加密明文大小
+     */
+    private static final int MAX_ENCRYPT_BLOCK = 116;
+
+    /**
+    /**
+     * RSA最大解密密文大小
+     */
+    private static final int MAX_DECRYPT_BLOCK = 128;
+
+    /**
+     * 生成公私密钥对
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, String> genKeyPair() throws Exception {
+        KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(Algorithm.RSA);
+        keyPairGen.initialize(KEY_SIZE);
+        KeyPair keyPair = keyPairGen.generateKeyPair();
+
+        final Map<String, String> keyMap = new HashMap<String, String>(2);
+        keyMap.put(PUBLIC_KEY, CodeUtil.base64Encode(keyPair.getPublic().getEncoded()));
+        keyMap.put(PRIVATE_KEY, CodeUtil.base64Encode(keyPair.getPrivate().getEncoded()));
+        return keyMap;
+    }
+
+    /**
+     * 生成RSA签名串
+     * @param data             需要生成签名串的数据
+     * @param mchPrivateKey    商户私钥
+     * @return
+     * @throws JPException
+     */
+    public static String sign(String data, String mchPrivateKey, boolean isSha) throws JPException {
+        try {
+            byte[] dataBytes = data.getBytes(CommonConst.ENCODING_UTF_8);
+            byte[] keyBytes = CodeUtil.base64Decode(mchPrivateKey);
+            String algorithm = isSha ? SIGNATURE_ALGORITHM_SHA1 : SIGNATURE_ALGORITHM_MD5;
+
+            PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+            PrivateKey priKey = KeyFactory.getInstance(Algorithm.RSA).generatePrivate(pkcs8KeySpec);
+            Signature signature = Signature.getInstance(algorithm);
+            signature.initSign(priKey);
+            signature.update(dataBytes);
+            return HEXUtil.encode(CodeUtil.base64Encode(signature.sign()));
+        }catch (Throwable e){
+            throw new JPException("生成RSA签名失败", e);
+        }
+    }
+
+    /**
+     * 验证RSA签名串
+     * @param data          需要验签的数据
+     * @param jpPublicKey   汇聚公钥
+     * @param sign          汇聚返回的签名串
+     * @return
+     * @throws JPException
+     */
+    public static boolean verify(String data, String jpPublicKey, String sign, boolean isSha) throws JPException {
+        try {
+            byte[] dataBytes = data.getBytes(CommonConst.ENCODING_UTF_8);
+            byte[] signBytes = CodeUtil.base64Decode(HEXUtil.decode(sign));
+            String algorithm = isSha ? SIGNATURE_ALGORITHM_SHA1 : SIGNATURE_ALGORITHM_MD5;
+            PublicKey publicK = getPublicKey(jpPublicKey);
+
+            Signature signature = Signature.getInstance(algorithm);
+            signature.initVerify(publicK);
+            signature.update(dataBytes);
+            return signature.verify(signBytes);
+        }catch (Throwable e){
+            throw new JPException("RSA验签失败", e);
+        }
+    }
+
+    /**
+     * 使用RSA进行加密
+     * @param data          需要加密的数据
+     * @param jpPublicKey   汇聚公钥
+     * @return
+     */
+    public static String encrypt(String data, String jpPublicKey) throws JPException {
+        try{
+            byte[] dataBytes = data.getBytes(CommonConst.ENCODING_UTF_8);
+            dataBytes = doCipher(dataBytes, jpPublicKey, true);
+            return HEXUtil.encode(CodeUtil.base64Encode(dataBytes));
+        }catch(Throwable e){
+            throw new JPException("RSA加密失败", e);
+        }
+    }
+
+    /**
+     * 使用RSA进行解密
+     * @param data              需要解密的数据
+     * @param mchPrivateKey     商户私钥
+     * @return
+     */
+    public static String decrypt(String data, String mchPrivateKey) throws JPException {
+        try{
+            byte[] dataBytes = CodeUtil.base64Decode(HEXUtil.decode(data));
+            dataBytes = doCipher(dataBytes, mchPrivateKey, false);
+            return new String(dataBytes, CommonConst.ENCODING_UTF_8);
+        }catch(Throwable e){
+            throw new JPException("RSA解密失败", e);
+        }
+    }
+
+    private static byte[] doCipher(byte[] dataBytes, String keyStr, boolean isEncrypt) throws Exception{
+        Key key;
+        Cipher cipher;
+        int maxBlock;
+
+        if(isEncrypt){
+            maxBlock = MAX_ENCRYPT_BLOCK;
+            key = getPublicKey(keyStr);
+            cipher = Cipher.getInstance(DEFAULT_ENCRYPT_ALGORITHM);
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+        }else{
+            maxBlock = MAX_DECRYPT_BLOCK;
+            byte[] keyBytes = CodeUtil.base64Decode(keyStr);
+            PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+            KeyFactory keyFactory = KeyFactory.getInstance(Algorithm.RSA);
+            Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+            cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+            cipher.init(Cipher.DECRYPT_MODE, privateK);
+        }
+
+        int offSet = 0, i = 0, inputLen = dataBytes.length;
+        byte[] cache;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        try{
+            // 对数据分段加密/解密
+            while (inputLen - offSet > 0) {
+                if (inputLen - offSet > maxBlock) {
+                    cache = cipher.doFinal(dataBytes, offSet, maxBlock);
+                } else {
+                    cache = cipher.doFinal(dataBytes, offSet, inputLen - offSet);
+                }
+                out.write(cache, 0, cache.length);
+                i++;
+                offSet = i * maxBlock;
+            }
+            return out.toByteArray();
+        } finally {
+            out.close();
+        }
+    }
+
+    private static PublicKey getPublicKey(String publicKey) throws Exception{
+        byte[] keyBytes = CodeUtil.base64Decode(publicKey);
+        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+        KeyFactory keyFactory = KeyFactory.getInstance(Algorithm.RSA);
+        return keyFactory.generatePublic(x509KeySpec);
+    }
+}

+ 14 - 0
src/main/java/com/szwl/model/utils/constants/Algorithm.java

@@ -0,0 +1,14 @@
+package com.szwl.model.utils.constants;
+
+/**
+ * 加解密运算时的逻辑算法名常量类
+ * @author: chenyf
+ * @Date: 2018-12-15
+ */
+public class Algorithm {
+    public final static String MD5 = "MD5";
+    public final static String AES = "AES";
+    public final static String RSA = "RSA";
+
+
+}

+ 12 - 0
src/main/java/com/szwl/model/utils/constants/CommonConst.java

@@ -0,0 +1,12 @@
+package com.szwl.model.utils.constants;
+
+/**
+ * 公共常量类
+ * @author: chenyf
+ * @Date: 2018-12-15
+ */
+public class CommonConst {
+    public static final String ENCODING_UTF_8 = "UTF-8";
+
+    public static final String AES_KEY_SEPARATOR = ":";
+}

+ 12 - 0
src/main/java/com/szwl/model/utils/exceptions/JPException.java

@@ -0,0 +1,12 @@
+package com.szwl.model.utils.exceptions;
+
+public class JPException extends RuntimeException {
+
+    public JPException(String message) {
+        super(message);
+    }
+
+    public JPException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

+ 3 - 0
src/main/java/com/szwl/service/TOrderService.java

@@ -1,7 +1,9 @@
 package com.szwl.service;
 
+import com.szwl.model.bean.ChartColumn;
 import com.szwl.model.entity.TOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.szwl.model.query.StatisticsParam;
 
 /**
  * <p>
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TOrderService extends IService<TOrder> {
 
+    ChartColumn getStatistics(StatisticsParam param);
 }

+ 186 - 0
src/main/java/com/szwl/service/es/EsTCoinOrderService.java

@@ -0,0 +1,186 @@
+package com.szwl.service.es;
+
+import cn.com.crbank.ommo.esclient.EsBaseService;
+import cn.com.crbank.ommo.exception.MyException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.szwl.model.entity.TCoinOrder;
+import com.szwl.model.query.TCoinOrderParam;
+import com.szwl.model.utils.DateUtils;
+import com.szwl.service.TCoinOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+@Slf4j
+@Service
+public class EsTCoinOrderService extends EsBaseService<TCoinOrder, TCoinOrderParam> {
+    private static boolean InitEsTableStatus = false; // 是否正常完成 es 初始化
+    public static final int MAX_ROW = 10000;
+    @Autowired
+    TCoinOrderService tCoinOrderService;
+
+    @Override
+    public String getTableName() {
+        return "es_t_coin_order";
+    }
+
+    @Override
+    public TCoinOrder getInstanceOfEntity() {
+        return new TCoinOrder();
+    }
+
+    @Override
+    public void setInitTableStatus(boolean flag) {
+        InitEsTableStatus = flag;
+    }
+
+    @Override
+    public boolean getInitTableStatus() {
+        return InitEsTableStatus;
+    }
+    @Override
+    public String getEntityPrimaryKey(TCoinOrder tCoinOrder) {
+        return String.valueOf(tCoinOrder.getId());
+    }
+
+    @Override
+    public TCoinOrder setEntityPrimaryKey(TCoinOrder tCoinOrder, String value) {
+        return null;
+    }
+
+//    @Override
+//    public TCoinOrder setEntityPrimaryKey(TCoinOrder tCoinOrder, String value) {
+//        return tCoinOrder.setId(Long.parseLong(value));
+//    }
+
+    @Override
+    public void initTableFun() {
+        try{
+            String tableName = getTableName();
+            GetIndexRequest request = new GetIndexRequest(tableName);
+//            DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(this.getTableName());
+//            restHighLevelClient.indices().delete(deleteIndexRequest,RequestOptions.DEFAULT);
+            boolean isExists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
+            if (!isExists) {
+                log.info("es 索引 开始创建"+tableName);
+                createTable();
+                // 初始化旧流水
+                int num = 0;
+                while (true) {
+                    int limit = MAX_ROW;
+//                    int offset= num * MAX_ROW;
+                    int offset= num;
+//                    TCoinOrderExample example = new TCoinOrderExample();
+//                    example.setLimit(limit);
+//                    example.setOffset(offset);
+//                    List<TCoinOrder> list = tCoinOrderService.selectByOption(example);
+                    LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
+                    Page<TCoinOrder> page = new Page<>(offset, limit, true);
+                    IPage<TCoinOrder> iPage = tCoinOrderService.page(page, query);
+                    List<TCoinOrder> list = iPage.getRecords();
+                    insertBatch(list);
+                    num++;
+                    if(list.size()< MAX_ROW){ // 数据小于 最大值 ,证明后面已无数据,则跳出
+                        break;
+                    }
+                }
+            } else {
+                log.info("es 索引 "+tableName+" 已存在不再创建");
+            }
+            InitEsTableStatus = true;
+        }catch (Exception e){
+            log.error("ElasticsearchRunner InitEsTCoinOrderThread 发生错误:{}" , e);
+            throw new MyException("ElasticsearchRunner InitEsTCoinOrderThread 发生错误:" + e.getMessage());
+        }
+    }
+
+    /**
+     * 根据时间 重新同步es
+     * @param
+     * @return
+     */
+    public void updateEsByDate(String startTime, String endTime) {
+        try {
+            startTime = startTime.replace("/", "-");
+            endTime = endTime.replace("/", "-");
+            Date start = DateUtils.parseDate(startTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+            Date end = DateUtils.parseDate(endTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+            // 查询es 现有的数据,删除
+            TCoinOrderParam param = new TCoinOrderParam();
+            param.setCreateDate_start(start);
+            param.setCreateDate_end(end);
+            List<TCoinOrder> list_es = this.selectEntityByEqualToOption(param);
+            for (TCoinOrder entity : list_es) {
+                this.deleteTableById(String.valueOf(entity.getId()));
+            }
+            // 插入 新的
+//            List<TCoinOrder> list = tCoinOrderService.selectForEs(param);
+            LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
+            query.gt(TCoinOrder::getCreateDate,start);
+            query.lt(TCoinOrder::getCreateDate,end);
+            List<TCoinOrder> list = tCoinOrderService.list(query);
+            if (CollectionUtils.isNotEmpty(list)) {
+                insertBatch(list);
+            }
+        } catch (Exception e) {
+            log.error(this.getTableName()+" updateEsByDate 发生错误:{}", e);
+            throw new MyException(this.getTableName()+" updateEsByDate 发生错误:" + e.getMessage());
+        }
+    }
+
+    public void tongbuByHour() throws ParseException {
+        String startDate = null;
+
+        String endDate = null;
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Calendar calendar = Calendar.getInstance();
+
+        calendar.setTime(new Date());
+
+        endDate = sdf.format(calendar.getTime());
+
+        calendar.add(calendar.HOUR_OF_DAY, -1);
+
+        startDate = sdf.format(calendar.getTime());
+        Date start = sdf.parse(startDate);
+        Date end = sdf.parse(endDate);
+        // 查询es 现有的数据
+//        TCoinOrderExample example = new TCoinOrderExample();
+//        TCoinOrderExample.Criteria criteria = example.createCriteria();
+//        criteria.andCreateDateGreaterThanOrEqualTo(start);
+//        criteria.andCreateDateLessThanOrEqualTo(end);
+//        criteria.andEsEqualTo("1");
+//        List<TCoinOrder> list_es = tCoinOrderService.selectByOption(example);
+        LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
+        query.gt(TCoinOrder::getCreateDate,start);
+        query.lt(TCoinOrder::getCreateDate,end);
+        List<TCoinOrder> list_es = tCoinOrderService.list(query);
+        if (CollectionUtils.isNotEmpty(list_es)) {
+//            insertBatch(list_es);
+            if(list_es.size()>0){
+                for(TCoinOrder coinOrder : list_es){
+                    try {
+                        updateDataById(coinOrder);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+
+        }
+    }
+}

+ 344 - 0
src/main/java/com/szwl/service/es/EsTEquipmentService.java

@@ -0,0 +1,344 @@
+package com.szwl.service.es;
+
+import cn.com.crbank.ommo.esclient.EsBaseService;
+import cn.com.crbank.ommo.exception.MyException;
+import com.szwl.model.bean.ChartBean;
+import com.szwl.model.bean.ChartColumn;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.query.StatisticsParam;
+import com.szwl.model.query.TCoinOrderParam;
+import com.szwl.model.query.TEquipmentParam;
+import com.szwl.model.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.Aggregations;
+import org.elasticsearch.search.aggregations.BucketOrder;
+import org.elasticsearch.search.aggregations.bucket.terms.Terms;
+import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
+import org.elasticsearch.search.aggregations.metrics.ParsedSum;
+import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+@Slf4j
+@Service
+public class EsTEquipmentService extends EsBaseService<TEquipment, TEquipmentParam> {
+    private static boolean InitEsTableStatus = false; // 是否正常完成 es 初始化
+    public static final int MAX_ROW = 10000;
+//    @Autowired
+//    TEquipmentService tEquipmentService;
+    @Autowired
+    EsTCoinOrderService esTCoinOrderService;
+    @Autowired
+    EsTOrderService esTOrderService;
+
+    @Override
+    public String getTableName() {
+        return "es_t_equipment";
+    }
+
+    @Override
+    public TEquipment getInstanceOfEntity() {
+        return new TEquipment();
+    }
+
+    @Override
+    public void setInitTableStatus(boolean flag) {
+        InitEsTableStatus = flag;
+    }
+
+    @Override
+    public boolean getInitTableStatus() {
+        return InitEsTableStatus;
+    }
+
+    @Override
+    public void initTableFun() {
+//        try{
+//            String tableName = getTableName();
+//            GetIndexRequest request = new GetIndexRequest(tableName);
+////            DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(this.getTableName());
+////            restHighLevelClient.indices().delete(deleteIndexRequest,RequestOptions.DEFAULT);
+//            boolean isExists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
+//            if (!isExists) {
+//                log.info("es 索引 开始创建"+tableName);
+//                createTable();
+//                // 初始化旧流水
+//                int num = 0;
+//                while (true) {
+//                    int limit = MAX_ROW;
+////                    int offset= num * MAX_ROW;
+//                    int offset= num;
+//
+//                    LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+//                    Page<TEquipment> page = new Page<>(offset, limit, true);
+//                    IPage<TEquipment> iPage = tEquipmentService.page(page, query);
+//                    List<TEquipment> list = iPage.getRecords();
+////                    TEquipmentExample example = new TEquipmentExample();
+////                    example.setLimit(limit);
+////                    example.setOffset(offset);
+////                    List<TEquipment> list = tEquipmentService.selectByOption(example);
+//                    insertBatch(list);
+//                    num++;
+//                    if(list.size()< MAX_ROW){ // 数据小于 最大值 ,证明后面已无数据,则跳出
+//                        break;
+//                    }
+//                }
+//            } else {
+//                log.info("es 索引 "+tableName+" 已存在不再创建");
+//            }
+//            InitEsTableStatus = true;
+//        }catch (Exception e){
+//            log.error("ElasticsearchRunner InitEsTEquipmentThread 发生错误:{}" , e);
+//            throw new MyException("ElasticsearchRunner InitEsTEquipmentThread 发生错误:" + e.getMessage());
+//        }
+    }
+
+    @Override
+    public String getEntityPrimaryKey(TEquipment tEquipment) {
+        return String.valueOf(tEquipment.getId());
+    }
+
+    @Override
+    public TEquipment setEntityPrimaryKey(TEquipment tEquipment, String value) {
+        return null;
+    }
+
+//    @Override
+//    public TEquipment setEntityPrimaryKey(TEquipment tEquipment, String value) {
+//        return tEquipment.setId(Long.parseLong(value));
+//    }
+    /**
+     * 根据时间 重新同步es
+     * @param
+     * @return
+     */
+    public void updateEsByDate(String startTime, String endTime) {
+//        try {
+//            startTime = startTime.replace("/", "-");
+//            endTime = endTime.replace("/", "-");
+//            Date start = DateUtils.parseDate(startTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+//            Date end = DateUtils.parseDate(endTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+//            // 查询es 现有的数据,删除
+//            TEquipmentParam param = new TEquipmentParam();
+//            param.setCreateDate_start(start);
+//            param.setCreateDate_end(end);
+//            List<TEquipment> list_es = this.selectEntityByEqualToOption(param);
+//            for (TEquipment entity : list_es) {
+//                this.deleteTableById(String.valueOf(entity.getId()));
+//            }
+//            // 插入 新的
+////            TEquipmentExample equipmentExample = new TEquipmentExample();
+////            TEquipmentExample.Criteria criteria =equipmentExample.createCriteria();
+////            criteria.andCreateDateBetween(start,end);
+////            List<TEquipment> list = tEquipmentService.selectByOption(equipmentExample);
+//            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+//            query.gt(TEquipment::getCreateDate,start);
+//            query.lt(TEquipment::getCreateDate,end);
+//            List<TEquipment> list = tEquipmentService.list(query);
+//            if (CollectionUtils.isNotEmpty(list)) {
+//                insertBatch(list);
+//            }
+//        } catch (Exception e) {
+//            log.error(this.getTableName()+" updateEsByDate 发生错误:{}", e);
+//            throw new MyException(this.getTableName()+" updateEsByDate 发生错误:" + e.getMessage());
+//        }
+    }
+
+
+    public ChartColumn getEquipmentStatistics(StatisticsParam param) {
+        if(StringUtils.equals("0",param.getIfForeign())) { // 国内用户
+            return getEquipmentStatistics_0(param);
+        }else{ // 国外用户
+            return getEquipmentStatistics_1(param);
+        }
+    }
+
+    /**
+     * 统计 国内
+     * @param param
+     * @return
+     */
+    public ChartColumn getEquipmentStatistics_0(StatisticsParam param) {
+//        BoolQueryBuilder boolQueryBuilder;
+//        String startDate = param.getStartDate().replace("/","-");
+//        String endDate = param.getEndDate().replace("/","-");
+//        Date start = DateUtils.parseDate(startDate+" 00:00:00",DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+//        Date end = DateUtils.parseDate(endDate+" 23:59:59",DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+//        TOrderParam tOrderParam = new TOrderParam();
+//        tOrderParam.setStatus(1);
+//
+//        tOrderParam.setCreateDate_start(start);
+//        tOrderParam.setCreateDate_end(end);
+//        if(StringUtils.isNotEmpty(param.getAdminId())){ // 所属商家id
+//            tOrderParam.setAdminId(Long.parseLong(param.getAdminId()));
+//        }
+//
+//        boolQueryBuilder = esTOrderService.getParam2QueryBuilder(tOrderParam);
+//        if("1".equals(param.getChangeType())){
+//            // 花型统计
+//            return getEquipmentStatistics(boolQueryBuilder,esTOrderService.getTableName(),"productName.keyword");
+//        }else{
+//            log.info("1");
+//            ChartColumn chartColumn = getEquipmentStatistics(boolQueryBuilder,esTOrderService.getTableName(),"equipmentId");
+//
+//            // 设置categories
+//            ArrayList<String> equipmentIdList = chartColumn.getCategories();
+//            List<Long> list = new ArrayList<>();
+//            for(String e:equipmentIdList){
+//                list.add(Long.valueOf(e));
+//            }
+////        TEquipmentParam tEquipmentParam = new TEquipmentParam();
+////        tEquipmentParam.setId_inList(equipmentIdList);
+////        List<TEquipment> equipmentList = this.selectEntityByEqualToOption(tEquipmentParam);
+////            TEquipmentExample exampe = new TEquipmentExample();
+////            TEquipmentExample.Criteria criteria = exampe.createCriteria();
+////            criteria.andIdIn(list);
+////            List<TEquipment> tEquipments = tEquipmentService.selectByOption(exampe);
+//            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+//            query.in(TEquipment::getId,list);
+//            List<TEquipment> tEquipments = tEquipmentService.list(query);
+//            ArrayList<String> categories_final = new ArrayList<>();
+//            for (String equipmentId : equipmentIdList) {
+//                String finalCategories =  equipmentId;
+////            Optional<TEquipment> op = equipmentList.stream().filter(
+//                Optional<TEquipment> op = tEquipments.stream().filter(
+//                        e ->{
+//                            return StringUtils.equals(String.valueOf(e.getId()),equipmentId);
+//                        }
+//                ).findFirst();
+//                if(op.isPresent()){
+//                    TEquipment equipment = op.get();
+//                    if(StringUtils.isNotEmpty(equipment.getName())){
+//                        finalCategories = equipment.getName();
+//                    }else{
+//                        finalCategories = equipment.getClientId().substring(equipment.getClientId().length()-6,equipment.getClientId().length());
+//                    }
+//                }
+//                categories_final.add(finalCategories);
+//            }
+//            chartColumn.setCategories(categories_final);
+//
+//            return chartColumn;
+//        }
+        return null;
+    }
+    /**
+     * 统计 国外
+     * @param param
+     * @return
+     */
+    public ChartColumn getEquipmentStatistics_1(StatisticsParam param) {
+        BoolQueryBuilder boolQueryBuilder;
+        String startDate = param.getStartDate().replace("/","-");
+        String endDate = param.getEndDate().replace("/","-");
+        Date start = DateUtils.parseDate(startDate+" 00:00:00", DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+        Date end = DateUtils.parseDate(endDate+" 23:59:59", DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+        TCoinOrderParam tCoinOrderParam = new TCoinOrderParam();
+
+//        tCoinOrderParam.setCreateDate_start(start);
+        tCoinOrderParam.setPayDate_start(start);
+//        tCoinOrderParam.setCreateDate_end(end);
+        tCoinOrderParam.setPayDate_end(end);
+        if(StringUtils.isNotEmpty(param.getAdminId())){ // 所属商家id
+            tCoinOrderParam.setAdminId(Long.parseLong(param.getAdminId()));
+        }
+
+        boolQueryBuilder = esTCoinOrderService.getParam2QueryBuilder(tCoinOrderParam);
+        if("1".equals(param.getChangeType())){
+            // 花型统计
+            return getEquipmentStatistics(boolQueryBuilder,esTCoinOrderService.getTableName(),"productName.keyword");
+        }else{
+            log.info("1");
+            ChartColumn chartColumn = getEquipmentStatistics(boolQueryBuilder,esTCoinOrderService.getTableName(),"clientId.keyword");
+
+            // 设置categories
+            ArrayList<String> clientIdList = chartColumn.getCategories();
+            TEquipmentParam tEquipmentParam = new TEquipmentParam();
+            tEquipmentParam.setClientId_inList(clientIdList);
+            List<TEquipment> equipmentList = this.selectEntityByEqualToOption(tEquipmentParam);
+
+            ArrayList<String> categories_final = new ArrayList<>();
+            for (String clientId : clientIdList) {
+                String finalCategories =  clientId.substring(0,4);
+                Optional<TEquipment> op = equipmentList.stream().filter(
+                        e ->{
+                            return StringUtils.equals(e.getClientId(),clientId);
+                        }
+                ).findFirst();
+                if(op.isPresent()){
+                    if(StringUtils.isNotEmpty(op.get().getName())){
+                        finalCategories = op.get().getName();
+                    }
+                }
+                categories_final.add(finalCategories);
+            }
+            chartColumn.setCategories(categories_final);
+            return chartColumn;
+        }
+    }
+
+    public ChartColumn getEquipmentStatistics(BoolQueryBuilder queryBuilder,String tableName ,String termField) {
+        try {
+            String aggregationResultName = "aggregationResult";//  仅为名称,用以获取返回结果
+            String aggSumName = "sales"; //  仅为名称,用以获取返回结果
+
+            // 根据字段 termField 聚合
+            TermsAggregationBuilder termsAggregationBuilder = AggregationBuilders.terms(aggregationResultName).field(termField);
+            termsAggregationBuilder.size(30); // 聚合后 返回前30条 记录
+            termsAggregationBuilder.order(BucketOrder.compound(
+                BucketOrder.aggregation(aggSumName,false)//先按sales,降序排
+            ));
+            // 根据字段price 求和 sum, sales 仅为名称,用以获取返回结果
+            SumAggregationBuilder sumAggregationBuilder = AggregationBuilders.sum(aggSumName).field("price");
+            termsAggregationBuilder.subAggregation(sumAggregationBuilder);
+            SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
+            // 指定size为0,不返回文档 因为只需要数量
+            sourceBuilder.query(queryBuilder).aggregation(termsAggregationBuilder).size(0);
+            SearchRequest searchRequest = new SearchRequest(tableName);
+            searchRequest.source(sourceBuilder);
+            log.debug("sourceBuilder:{}", sourceBuilder);
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            Aggregations aggregations = searchResponse.getAggregations();
+            Terms terms = aggregations.get(aggregationResultName);
+
+            List<ChartBean> chartBeanList = new ArrayList<>();
+            for (Terms.Bucket bucket : terms.getBuckets()) {
+                ChartBean chartBean = new ChartBean();
+                chartBean.setCategorie(bucket.getKeyAsString());
+//                chartBean.setSaleNum(Long.valueOf(bucket.getDocCount()).intValue());
+                chartBean.setSaleNum(Float.valueOf(bucket.getDocCount()));
+                ParsedSum sum = bucket.getAggregations().get(aggSumName);
+//                chartBean.setSalePrice(Double.valueOf(sum.getValue()).intValue());
+                String s = format1((float)sum.getValue());
+                chartBean.setSalePrice(Float.valueOf(s));
+                chartBeanList.add(chartBean);
+            }
+            log.debug("chartBeanList:{}",chartBeanList);
+            ChartColumn chartColumn = new ChartColumn(chartBeanList);
+            return chartColumn;
+        } catch (Exception e) {
+            log.error(getTableName() + " es根据条件 聚合查询 报错:{}", e);
+            throw new MyException(getTableName() + " es根据条件 聚合查询 报错:" + e.getMessage());
+        }
+    }
+    public static String format1(Float value){
+        BigDecimal bd = new BigDecimal(value);//创建一个bd对象,将要转换的值value传入构造函数
+        bd = bd.setScale(2, RoundingMode.HALF_UP);//调用setScale方法进行数据格式化,保留两位小数,采用四舍五入规则
+        return bd.toString(); //返回bd对象的值(转化为string形式)
+    }
+
+}

+ 364 - 0
src/main/java/com/szwl/service/es/EsTOrderService.java

@@ -0,0 +1,364 @@
+package com.szwl.service.es;
+
+import cn.com.crbank.ommo.esclient.EsBaseService;
+import cn.com.crbank.ommo.exception.MyException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.szwl.model.bean.ChartBean;
+import com.szwl.model.bean.ChartColumn;
+import com.szwl.model.bo.ChartType;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TOrder;
+import com.szwl.model.query.StatisticsParam;
+import com.szwl.model.query.TCoinOrderParam;
+import com.szwl.model.query.TEquipmentParam;
+import com.szwl.model.query.TOrderParam;
+import com.szwl.model.utils.DateUtils;
+import com.szwl.service.TOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.search.aggregations.Aggregation;
+import org.elasticsearch.search.aggregations.AggregationBuilder;
+import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
+import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
+import org.elasticsearch.search.aggregations.metrics.ParsedSum;
+import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class EsTOrderService extends EsBaseService<TOrder, TOrderParam> {
+    private static boolean InitEsTableStatus = false; // 是否正常完成 es 初始化
+    public static final int MAX_ROW = 10000;
+    @Autowired
+    TOrderService tOrderService;
+    @Autowired
+    EsTEquipmentService esTEquipmentService;
+    @Autowired
+    EsTCoinOrderService esTCoinOrderService;
+
+    @Override
+    public String getTableName() {
+        return "es_t_order";
+    }
+//    public String getTableName() {
+//        return "es_t_order";
+//    }
+
+    @Override
+    public TOrder getInstanceOfEntity() {
+        return new TOrder();
+    }
+
+    @Override
+    public void setInitTableStatus(boolean flag) {
+        InitEsTableStatus = flag;
+    }
+
+    @Override
+    public boolean getInitTableStatus() {
+        return InitEsTableStatus;
+    }
+
+    @Override
+    public void initTableFun() {
+        try{
+            String tableName = getTableName();
+            GetIndexRequest request = new GetIndexRequest(tableName);
+//            DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(this.getTableName());
+//            restHighLevelClient.indices().delete(deleteIndexRequest,RequestOptions.DEFAULT);
+            boolean isExists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
+            if (!isExists) {
+                log.info("es 索引 开始创建"+tableName);
+                createTable();
+                // 初始化旧流水
+                int num = 0;
+                while (true) {
+                    int limit = MAX_ROW;
+//                    int offset= num * MAX_ROW;
+                    int offset= num;
+//                    TOrderExample example = new TOrderExample();
+//                    example.setLimit(limit);
+//                    example.setOffset(offset);
+//                    List<TOrder> list = tOrderService.selectByOption(example);
+                    LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
+                    Page<TOrder> page = new Page<>(offset, limit, true);
+                    IPage<TOrder> iPage = tOrderService.page(page, query);
+                    List<TOrder> list = iPage.getRecords();
+                    insertBatch(list);
+                    num++;
+                    if(list.size()< MAX_ROW){ // 数据小于 最大值 ,证明后面已无数据,则跳出
+                        break;
+                    }
+                }
+            } else {
+                log.info("es 索引 "+tableName+" 已存在不再创建");
+            }
+            InitEsTableStatus = true;
+        }catch (Exception e){
+            log.error("ElasticsearchRunner InitEsTOrderThread 发生错误:{}" , e);
+            throw new MyException("ElasticsearchRunner InitEsTOrderThread 发生错误:" + e.getMessage());
+        }
+    }
+
+    @Override
+    public String getEntityPrimaryKey(TOrder tOrder) {
+        return String.valueOf(tOrder.getId());
+    }
+
+    @Override
+    public TOrder setEntityPrimaryKey(TOrder tOrder, String value) {
+        return null;
+    }
+
+//    @Override
+//    public TOrder setEntityPrimaryKey(TOrder tOrder, String value) {
+//        return tOrder.setId(Long.parseLong(value));
+//    }
+
+    /**
+     * 根据时间 重新同步es
+     * @param
+     * @return
+     */
+    public void updateEsByDate(String startTime, String endTime) {
+        try {
+            startTime = startTime.replace("/", "-");
+            endTime = endTime.replace("/", "-");
+            Date start = DateUtils.parseDate(startTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+            Date end = DateUtils.parseDate(endTime, DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss, new Date());
+            // 查询es 现有的数据,删除
+            TOrderParam param = new TOrderParam();
+            param.setCreateDate_start(start);
+            param.setCreateDate_end(end);
+            List<TOrder> list_es = this.selectEntityByEqualToOption(param);
+            for (TOrder entity : list_es) {
+                this.deleteTableById(String.valueOf(entity.getId()));
+            }
+            // 插入 新的
+//            List<TOrder> list = tOrderService.selectForEs(param);
+            LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
+            query.gt(TOrder::getCreateDate,start);
+            query.lt(TOrder::getCreateDate,end);
+            List<TOrder> list = tOrderService.list(query);
+            if (CollectionUtils.isNotEmpty(list)) {
+                insertBatch(list);
+            }
+        } catch (Exception e) {
+            log.error(this.getTableName()+" updateEsByDate 发生错误:{}", e);
+            throw new MyException(this.getTableName()+" updateEsByDate 发生错误:" + e.getMessage());
+        }
+    }
+
+
+    /**
+     * es 查询条件
+     * @param param
+     * @return
+     */
+    public BoolQueryBuilder getStatisticsParam2QueryBuilder(StatisticsParam param){
+        BoolQueryBuilder boolQueryBuilder;
+        String startDate = param.getStartDate().replace("/","-");
+        String endDate = param.getEndDate().replace("/","-");
+        Date start = DateUtils.parseDate(startDate+" 00:00:00", DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+        Date end = DateUtils.parseDate(endDate+" 23:59:59", DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss,new Date());
+
+        if(StringUtils.equals("0",param.getIfForeign())){ // 国内用户
+            TOrderParam tOrderParam = new TOrderParam();
+            tOrderParam.setStatus(1);
+            tOrderParam.setCreateDate_start(start);
+            tOrderParam.setCreateDate_end(end);
+            if(StringUtils.isNotEmpty(param.getAdminId())){ // 所属商家id
+                tOrderParam.setAdminId(Long.parseLong(param.getAdminId()));
+            }
+            if(StringUtils.isNotEmpty(param.getEquipmentId())){ // 设备id
+                tOrderParam.setEquipmentId(Long.parseLong(param.getEquipmentId()));
+            }
+            if (null != param.getAgencyId()){
+                tOrderParam.setAgencyId(param.getAgencyId());
+                tOrderParam.setType_gt(1);
+            }
+            if(null != param.getMerchantId()){
+                tOrderParam.setMerchantId(param.getMerchantId());
+                tOrderParam.setType_gt(2);
+            }
+
+            boolQueryBuilder = this.getParam2QueryBuilder(tOrderParam);
+
+        }else{ // 国外用户
+            TEquipmentParam tEquipmentParam = new TEquipmentParam();
+            if(StringUtils.isNotEmpty(param.getEquipmentId())){ // 设备id
+                tEquipmentParam.setId(Long.parseLong(param.getEquipmentId()));
+            }
+            List<TEquipment> equipmentList = esTEquipmentService.selectEntityByEqualToOption(tEquipmentParam);
+            List<String> clientIdList = equipmentList.stream().map(TEquipment::getClientId).collect(Collectors.toList());
+
+            TCoinOrderParam tCoinOrderParam = new TCoinOrderParam();
+            tCoinOrderParam.setCreateDate_start(start);
+            tCoinOrderParam.setCreateDate_end(end);
+            tCoinOrderParam.setClientId_inList(clientIdList);
+            if(StringUtils.isNotEmpty(param.getAdminId())){ // 所属商家id
+                tCoinOrderParam.setAdminId(Long.parseLong(param.getAdminId()));
+            }
+            boolQueryBuilder = esTCoinOrderService.getParam2QueryBuilder(tCoinOrderParam);
+        }
+        return boolQueryBuilder;
+    }
+
+    public ChartColumn getStatistics(StatisticsParam param) {
+        String msg = "";
+        String format = "yyyy-MM";
+        DateHistogramInterval interval = DateHistogramInterval.DAY;
+
+        if (ChartType.day.toString().equals(param.getChartType())) {
+            interval = DateHistogramInterval.HOUR;
+            format = "HH点";
+            msg = "日统计";
+        }
+        if (ChartType.week.toString().equals(param.getChartType())) {
+            interval = DateHistogramInterval.DAY;
+            format = "yyyy-MM-dd";
+            msg = "周统计";
+        }
+        if (ChartType.month.toString().equals(param.getChartType())) {
+            interval = DateHistogramInterval.DAY;
+            format = "MM月dd";
+            msg = "月统计";
+        }
+        if (ChartType.year.toString().equals(param.getChartType())) {
+            interval = DateHistogramInterval.MONTH;
+            format = "MM月";
+            msg = "年统计";
+        }
+
+        ChartColumn chartColumn = getStatistics(param,format,interval);
+        if (ChartType.week.toString().equals(param.getChartType())) {
+            ArrayList<String> categories = new ArrayList<>();
+            for (String day :chartColumn.getCategories()) {
+                int week = DateUtils.getWeek(DateUtils.parseDate(day, DateUtils.PATTERN_yyyy_MM_dd,new Date()));
+                String finalCategories = "周" + (week==0?"日":week);
+                categories.add(finalCategories);
+            }
+            chartColumn.setCategories(categories);
+        }
+        return chartColumn;
+    }
+
+
+    public ChartColumn getStatistics(StatisticsParam param, String format, DateHistogramInterval interval) {
+        try {
+            String aggregationResultName = "aggregationResult";//  仅为名称,用以获取返回结果
+            String aggSumName = "sales"; //  仅为名称,用以获取返回结果
+
+            //Bool查询
+            BoolQueryBuilder queryBuilder = getStatisticsParam2QueryBuilder(param);
+            // 时间聚合
+            AggregationBuilder dateHistogram = AggregationBuilders.dateHistogram(aggregationResultName)
+                    .field("createDate")
+                    .calendarInterval(interval)
+                    .format(format);
+
+            // 根据字段price 求和 sum, sales 仅为名称,用以获取返回结果
+            SumAggregationBuilder sumAggregationBuilder = AggregationBuilders.sum(aggSumName).field("price");
+            dateHistogram.subAggregation(sumAggregationBuilder);
+            SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
+            // 指定size为0,不返回文档 因为只需要数量
+            sourceBuilder.query(queryBuilder).aggregation(dateHistogram).size(0);
+            SearchRequest searchRequest = new SearchRequest(getTableName());
+            searchRequest.source(sourceBuilder);
+            log.debug("sourceBuilder:{}", sourceBuilder);
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            Aggregation agg = searchResponse.getAggregations().get(aggregationResultName);
+            List<? extends Histogram.Bucket> buckets = ((Histogram) agg).getBuckets();
+
+
+            List<ChartBean> chartBeanList = new ArrayList<>();
+            for (Histogram.Bucket bucket : buckets) {
+                ChartBean chartBean = new ChartBean();
+                chartBean.setCategorie(bucket.getKeyAsString());
+                chartBean.setSaleNum(Float.valueOf(bucket.getDocCount()));
+//                chartBean.setSaleNum(Long.valueOf(bucket.getDocCount()).intValue());
+                ParsedSum sum = bucket.getAggregations().get(aggSumName);
+                String s = format1((float) sum.getValue());
+                chartBean.setSalePrice(Float.valueOf(s));
+//                chartBean.setSalePrice(Double.valueOf(sum.getValue()).intValue());
+                chartBeanList.add(chartBean);
+            }
+            ChartColumn chartColumn = new ChartColumn(chartBeanList);
+            return chartColumn;
+        } catch (Exception e) {
+            log.error(getTableName() + " es根据条件 聚合查询 报错:{}", e);
+            throw new MyException(getTableName() + " es根据条件 聚合查询 报错:" + e.getMessage());
+        }
+    }
+
+    public static String format1(Float value){
+        BigDecimal bd = new BigDecimal(value);//创建一个bd对象,将要转换的值value传入构造函数
+        bd = bd.setScale(2, RoundingMode.HALF_UP);//调用setScale方法进行数据格式化,保留两位小数,采用四舍五入规则
+        return bd.toString(); //返回bd对象的值(转化为string形式)
+    }
+    public void tongbuByHour() throws ParseException {
+        String startDate = null;
+
+        String endDate = null;
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Calendar calendar = Calendar.getInstance();
+
+        calendar.setTime(new Date());
+
+        endDate = sdf.format(calendar.getTime());
+
+        calendar.add(calendar.HOUR_OF_DAY, -1);
+//        calendar.add(calendar.DATE, -4);
+
+        startDate = sdf.format(calendar.getTime());
+        Date start = sdf.parse(startDate);
+        Date end = sdf.parse(endDate);
+        // 查询es 现有的数据
+//        TOrderExample example = new TOrderExample();
+//        TOrderExample.Criteria criteria = example.createCriteria();
+//        criteria.andCreateDateGreaterThanOrEqualTo(start);
+//        criteria.andCreateDateLessThanOrEqualTo(end);
+//        criteria.andEsEqualTo("1");
+//        List<TOrder> list_es = tOrderService.selectByOption(example);
+        LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
+        query.gt(TOrder::getCreateDate,start);
+        query.lt(TOrder::getCreateDate,end);
+        List<TOrder> list_es = tOrderService.list(query);
+        if (CollectionUtils.isNotEmpty(list_es)) {
+            insertBatch(list_es);
+            if(list_es.size()>0){
+                for(TOrder order : list_es){
+                    try {
+                        updateDataById(order);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+}

+ 36 - 0
src/main/java/com/szwl/service/impl/TOrderServiceImpl.java

@@ -1,11 +1,19 @@
 package com.szwl.service.impl;
 
+import com.szwl.model.bean.ChartBean;
+import com.szwl.model.bean.ChartColumn;
+import com.szwl.model.bo.ChartType;
 import com.szwl.model.entity.TOrder;
 import com.szwl.mapper.TOrderMapper;
+import com.szwl.model.query.StatisticsParam;
 import com.szwl.service.TOrderService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -16,5 +24,33 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {
+    @Autowired
+    TOrderMapper tOrderMapper;
+    @Override
+    public ChartColumn getStatistics(StatisticsParam param) {
+        List<ChartBean> list = new ArrayList<>();
+        String msg = "";
+        if (ChartType.day.toString().equals(param.getChartType())) {
+            list = tOrderMapper.getDayStatistics(param);
+            msg = "日统计";
+        }
+        if (ChartType.week.toString().equals(param.getChartType())) {
+            list = tOrderMapper.getWeekStatistics(param);
+            msg = "周统计";
+        }
+        if (ChartType.month.toString().equals(param.getChartType())) {
+            list = tOrderMapper.getMonthStatistics(param);
+            msg = "月统计";
+        }
+        if (ChartType.year.toString().equals(param.getChartType())) {
+            list = tOrderMapper.getYearStatistics(param);
+            msg = "年统计";
+        }
 
+//        if (CollectionUtils.isEmpty(list)) {
+//            throw new MyException("获取" + msg + "数据为空");
+//        }
+        ChartColumn chartColumn = new ChartColumn(list);
+        return chartColumn;
+    }
 }

+ 8 - 1
src/main/resources/bootstrap.yml

@@ -13,7 +13,14 @@ spring:
     username: root
     password: sunzee@020
     driver-class-name: com.mysql.jdbc.Driver
-
+elasticSearch:
+  host: 120.78.140.173
+#elasticSearch.host: 10.0.0.155
+  port: 9200
+  client.connectNum: 1000
+  connectPerRoute: 50
+  client.esUserName: elastic
+  client.esPassword: sunzee@020
 server:
   port: 49012