Pārlūkot izejas kodu

Merge branch 'test'

Ritchie 1 gadu atpakaļ
vecāks
revīzija
2b305bcc5b
67 mainītis faili ar 3188 papildinājumiem un 1125 dzēšanām
  1. 312 290
      pom.xml
  2. 1 1
      src/main/java/com/szwl/aspect/MyWebMvcConfigurer.java
  3. 60 0
      src/main/java/com/szwl/constant/ConfigConsts.java
  4. 2 1
      src/main/java/com/szwl/controller/ADIndexController.java
  5. 64 33
      src/main/java/com/szwl/controller/AlarmRecordIndexController.java
  6. 169 154
      src/main/java/com/szwl/controller/IndexController.java
  7. 47 14
      src/main/java/com/szwl/controller/ScheduledService.java
  8. 29 2
      src/main/java/com/szwl/controller/TAdminController.java
  9. 195 0
      src/main/java/com/szwl/controller/TAlarmCleanController.java
  10. 4 4
      src/main/java/com/szwl/controller/TAlarmClockController.java
  11. 109 34
      src/main/java/com/szwl/controller/TEquipmentApplyController.java
  12. 131 73
      src/main/java/com/szwl/controller/TEquipmentController.java
  13. 6 20
      src/main/java/com/szwl/controller/TJoinpayMchController.java
  14. 14 40
      src/main/java/com/szwl/controller/TLabelController.java
  15. 48 35
      src/main/java/com/szwl/controller/TLocationCheckController.java
  16. 2 17
      src/main/java/com/szwl/controller/TLogoController.java
  17. 5 4
      src/main/java/com/szwl/controller/TMessageCodeController.java
  18. 6 0
      src/main/java/com/szwl/controller/TNoticeController.java
  19. 12 15
      src/main/java/com/szwl/controller/TOrderController.java
  20. 53 56
      src/main/java/com/szwl/controller/TParametersController.java
  21. 17 1
      src/main/java/com/szwl/controller/TProductController.java
  22. 238 172
      src/main/java/com/szwl/controller/TPromoCodeController.java
  23. 2 2
      src/main/java/com/szwl/controller/TProportionController.java
  24. 1 1
      src/main/java/com/szwl/controller/TTimeRuleController.java
  25. 73 12
      src/main/java/com/szwl/controller/TWechatController.java
  26. 0 46
      src/main/java/com/szwl/controller/TestController.java
  27. 67 3
      src/main/java/com/szwl/controller/WxLoginController.java
  28. 16 0
      src/main/java/com/szwl/mapper/TAlarmCleanMapper.java
  29. 2 0
      src/main/java/com/szwl/mapper/TEquipmentMapper.java
  30. 2 1
      src/main/java/com/szwl/mapper/TLocationCheckMapper.java
  31. 1 1
      src/main/java/com/szwl/mapper/TParametersMapper.java
  32. 7 1
      src/main/java/com/szwl/mapper/xml/TAdminMapper.xml
  33. 23 0
      src/main/java/com/szwl/mapper/xml/TAlarmCleanMapper.xml
  34. 27 2
      src/main/java/com/szwl/mapper/xml/TEquipmentMapper.xml
  35. 2 2
      src/main/java/com/szwl/mapper/xml/TLocationCheckMapper.xml
  36. 2 1
      src/main/java/com/szwl/mapper/xml/TNoticeMapper.xml
  37. 2 1
      src/main/java/com/szwl/mapper/xml/TParametersMapper.xml
  38. 28 0
      src/main/java/com/szwl/model/bean/WeChatTemplateMsg.java
  39. 4 1
      src/main/java/com/szwl/model/dto/PromoCodeTarget.java
  40. 57 0
      src/main/java/com/szwl/model/dto/PromoCodeTargetEn.java
  41. 19 2
      src/main/java/com/szwl/model/entity/TAdmin.java
  42. 55 0
      src/main/java/com/szwl/model/entity/TAlarmClean.java
  43. 7 1
      src/main/java/com/szwl/model/entity/TNotice.java
  44. 3 1
      src/main/java/com/szwl/model/entity/TParameters.java
  45. 22 0
      src/main/java/com/szwl/model/param/AlarmCleanParam.java
  46. 263 0
      src/main/java/com/szwl/model/utils/SampleMail.java
  47. 30 0
      src/main/java/com/szwl/service/TAlarmCleanService.java
  48. 16 3
      src/main/java/com/szwl/service/TEquipmentService.java
  49. 2 0
      src/main/java/com/szwl/service/TMessageCodeService.java
  50. 1 1
      src/main/java/com/szwl/service/TParametersService.java
  51. 3 0
      src/main/java/com/szwl/service/TPromoCodeService.java
  52. 42 0
      src/main/java/com/szwl/service/TWechatService.java
  53. 69 0
      src/main/java/com/szwl/service/impl/TAlarmCleanServiceImpl.java
  54. 1 1
      src/main/java/com/szwl/service/impl/TEquipmentDeletedServiceImpl.java
  55. 169 4
      src/main/java/com/szwl/service/impl/TEquipmentServiceImpl.java
  56. 2 2
      src/main/java/com/szwl/service/impl/THuifuMchServiceImpl.java
  57. 2 2
      src/main/java/com/szwl/service/impl/TJoinpayMchServiceImpl.java
  58. 30 65
      src/main/java/com/szwl/service/impl/TLocationCheckServiceImpl.java
  59. 19 1
      src/main/java/com/szwl/service/impl/TMessageCodeServiceImpl.java
  60. 1 1
      src/main/java/com/szwl/service/impl/TParametersServiceImpl.java
  61. 32 0
      src/main/java/com/szwl/service/impl/TPromoCodeServiceImpl.java
  62. 252 0
      src/main/java/com/szwl/service/impl/TWechatServiceImpl.java
  63. 134 0
      src/main/java/com/szwl/util/WechatSendUtil.java
  64. 51 0
      src/main/java/com/szwl/util/geoCoderUtil.java
  65. 1 1
      src/test/java/com/szwl/AutoGeneratorTests.java
  66. 51 0
      src/test/java/com/szwl/controller/TestController.java
  67. 71 0
      src/test/java/com/szwl/service/impl/TEquipmentServiceImplTest.java

+ 312 - 290
pom.xml

@@ -1,32 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
 
-	<groupId>com.szwl</groupId>
-	<artifactId>szwlServer</artifactId>
-	<version>0.0.1</version>
-	<packaging>jar</packaging>
+    <groupId>com.szwl</groupId>
+    <artifactId>szwlServer</artifactId>
+    <version>0.0.1</version>
+    <packaging>jar</packaging>
 
-	<name>szwlServer</name>
+    <name>szwlServer</name>
 
-	<parent>
-		<groupId>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>2.3.12.RELEASE</version>
-	</parent>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.12.RELEASE</version>
+    </parent>
 
 
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-		<java.version>1.8</java.version>
-		<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
-<!--		<mybatis-spring-boot-starter.version>2.2.0</mybatis-spring-boot-starter.version>-->
-		<mybatis-plus.version>3.4.0</mybatis-plus.version>
-		<mybatis.version>3.5.7</mybatis.version>
-	</properties>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
+        <!--		<mybatis-spring-boot-starter.version>2.2.0</mybatis-spring-boot-starter.version>-->
+        <mybatis-plus.version>3.4.0</mybatis-plus.version>
+        <mybatis.version>3.5.7</mybatis.version>
+    </properties>
 
 	<dependencyManagement>
 		<dependencies>
@@ -55,279 +55,301 @@
 		</dependencies>
 	</dependencyManagement>
 
-	<dependencies>
-		<!-- springcloud组件 start -->
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-web</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-openfeign</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-config</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-actuator</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-		</dependency>
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.boot</groupId>-->
-<!--			<artifactId>spring-boot-starter-jdbc</artifactId>-->
-<!--		</dependency>-->
-		<!-- springcloud组件 end -->
-		<dependency>
-			<groupId>org.projectlombok</groupId>
-			<artifactId>lombok</artifactId>
-		</dependency>
+    <dependencies>
+        <!-- springcloud组件 start -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-config</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!--		<dependency>-->
+        <!--			<groupId>org.springframework.boot</groupId>-->
+        <!--			<artifactId>spring-boot-starter-jdbc</artifactId>-->
+        <!--		</dependency>-->
+        <!-- springcloud组件 end -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
 
-		<!-- mybatis-plus -->
-		<dependency>
-			<groupId>com.baomidou</groupId>
-			<artifactId>mybatis-plus-boot-starter</artifactId>
-		</dependency>
-		<!--mybatisplus代码生成 start -->
-		<dependency>
-			<groupId>com.baomidou</groupId>
-			<artifactId>mybatis-plus-generator</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.velocity</groupId>
-			<artifactId>velocity-engine-core</artifactId>
-			<version>2.2</version>
-		</dependency>
-		<!--mybatisplus代码生成 end -->
-		<dependency>
-			<groupId>mysql</groupId>
-			<artifactId>mysql-connector-java</artifactId>
-		</dependency>
-		<!-- swagger2 -->
-		<dependency>
-			<groupId>com.github.xiaoymin</groupId>
-			<artifactId>knife4j-spring-boot-starter</artifactId>
-			<version>3.0.3</version>
-		</dependency>
-		<dependency>
-			<groupId>ch.ethz.ganymed</groupId>
-			<artifactId>ganymed-ssh2</artifactId>
-			<version>build210</version>
-		</dependency>
-		<!-- json -->
-		<dependency>
-			<groupId>com.alibaba</groupId>
-			<artifactId>fastjson</artifactId>
-			<version>1.2.75</version>
-		</dependency>
-		<!-- Spring Component End -->
-		<dependency>
-			<groupId>org.json</groupId>
-			<artifactId>json</artifactId>
-			<version>20200518</version>
-		</dependency>
-		<!--邮箱-->
-		<dependency>
-			<groupId>javax.mail</groupId>
-			<artifactId>mail</artifactId>
-			<version>1.4.7</version>
-		</dependency>
-		<!-- hutool -->
-		<dependency>
-			<groupId>cn.hutool</groupId>
-			<artifactId>hutool-core</artifactId>
-			<version>5.7.16</version>
-		</dependency>
-		<dependency>
-			<groupId>cn.hutool</groupId>
-			<artifactId>hutool-http</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</artifactId>-->
-			<!--<version>3.6.10</version>-->
-		<!--</dependency>-->
-		<dependency>
-			<groupId>org.hibernate</groupId>
-			<artifactId>hibernate-core</artifactId>
-			<version>3.6.10.Final</version>
-		</dependency>
-		<!-- 个推 -->
-		<dependency>
-			<groupId>com.gexin.platform</groupId>
-			<artifactId>gexin-rp-sdk-http</artifactId>
-			<version>4.0.1.9</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.11</version>
-		</dependency>
-		<!--redis start-->
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-data-redis</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-pool2</artifactId>
-		</dependency>
-		<!--redis end-->
-		<!--杉德支付-->
-		<dependency>
-			<groupId>cn.com.sand</groupId>
-			<artifactId>hmpay-sdk</artifactId>
-			<version>1.1.4</version>
-		</dependency>
-		<!--汇付支付-->
-		<dependency>
-			<groupId>com.huifu.bspay.sdk</groupId>
-			<artifactId>dg-java-sdk</artifactId>
-			<version>3.0.8</version>
-		</dependency>
-		<!-- 导出Excel -->
-		<dependency>
-			<groupId>cn.afterturn</groupId>
-			<artifactId>easypoi-base</artifactId>
-			<version>4.4.0</version>
-		</dependency>
-		<!--定时任务-->
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.boot</groupId>-->
-<!--			<artifactId>spring-boot-starter-web</artifactId>-->
-<!--		</dependency>-->
+        <!-- mybatis-plus -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <!--mybatisplus代码生成 start -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.2</version>
+        </dependency>
+        <!--mybatisplus代码生成 end -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- swagger2 -->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.ethz.ganymed</groupId>
+            <artifactId>ganymed-ssh2</artifactId>
+            <version>build210</version>
+        </dependency>
+        <!-- json -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.75</version>
+        </dependency>
+        <!-- Spring Component End -->
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20200518</version>
+        </dependency>
+        <!--邮箱-->
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>1.4.7</version>
+        </dependency>
 
-		<dependency>
-			<groupId>com.squareup.okhttp3</groupId>
-			<artifactId>okhttp</artifactId>
-			<version>4.9.3</version>
-		</dependency>
+        <!-- Direct Mail -->
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+            <version>1.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+            <version>1.1.1</version>
+        </dependency>
 
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter</artifactId>
-		</dependency>
+        <!-- hutool -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-core</artifactId>
+            <version>5.7.16</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-http</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</artifactId>-->
+        <!--<version>3.6.10</version>-->
+        <!--</dependency>-->
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-core</artifactId>
+            <version>3.6.10.Final</version>
+        </dependency>
+        <!-- 个推 -->
+        <dependency>
+            <groupId>com.gexin.platform</groupId>
+            <artifactId>gexin-rp-sdk-http</artifactId>
+            <version>4.0.1.9</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.11</version>
+        </dependency>
+        <!--redis start-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <!--redis end-->
+        <!--杉德支付-->
+        <dependency>
+            <groupId>cn.com.sand</groupId>
+            <artifactId>hmpay-sdk</artifactId>
+            <version>1.1.4</version>
+        </dependency>
+        <!--汇付支付-->
+        <dependency>
+            <groupId>com.huifu.bspay.sdk</groupId>
+            <artifactId>dg-java-sdk</artifactId>
+            <version>3.0.8</version>
+        </dependency>
+        <!-- 导出Excel -->
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-base</artifactId>
+            <version>4.4.0</version>
+        </dependency>
+        <!--定时任务-->
+        <!--		<dependency>-->
+        <!--			<groupId>org.springframework.boot</groupId>-->
+        <!--			<artifactId>spring-boot-starter-web</artifactId>-->
+        <!--		</dependency>-->
 
-<!--		<dependency>-->
-<!--			<groupId>org.projectlombok</groupId>-->
-<!--			<artifactId>lombok</artifactId>-->
-<!--			<optional>true</optional>-->
-<!--		</dependency>-->
-<!--		<dependency>-->
-<!--			<groupId>org.springframework.boot</groupId>-->
-<!--			<artifactId>spring-boot-starter-test</artifactId>-->
-<!--			<scope>test</scope>-->
-<!--		</dependency>-->
-		<!--elasticsearch-->
-		<dependency>
-			<groupId>org.elasticsearch</groupId>
-			<artifactId>elasticsearch</artifactId>
-			<version>7.6.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.elasticsearch.client</groupId>
-			<artifactId>elasticsearch-rest-high-level-client</artifactId>
-			<version>7.6.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.elasticsearch.client</groupId>
-			<artifactId>elasticsearch-rest-client</artifactId>
-			<version>7.6.2</version>
-		</dependency>
-		<!-- 七牛云 -->
-		<dependency>
-			<groupId>com.qiniu</groupId>
-			<artifactId>qiniu-java-sdk</artifactId>
-			<version>7.13.0</version>
-		</dependency>
-		<dependency>
-			<groupId>com.google.code.gson</groupId>
-			<artifactId>gson</artifactId>
-		</dependency>
-	</dependencies>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>4.9.3</version>
+        </dependency>
 
-	<build>
-		<resources>
-			<resource>
-				<directory>src/main/java</directory>
-				<includes>
-					<include>**/*.xml</include>
-					<include>**/*.*</include>
-				</includes>
-				<!-- 是否替换资源中的属性 -->
-				<filtering>false</filtering>
-			</resource>
-			<resource>
-				<directory>src/main/resources</directory>
-				<includes>
-					<include>**/*.*</include>
-				</includes>
-				<!-- 是否替换资源中的属性 -->
-				<filtering>false</filtering>
-			</resource>
-		</resources>
-		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-				<configuration>
-					<layout>ZIP</layout>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-	<repositories>
-		<!-- 个推 -->
-		<repository>
-			<id>getui-nexus</id>
-			<url>http://mvn.gt.igexin.com/nexus/content/repositories/releases/</url>
-		</repository>
-		<repository>
-			<id>nexus</id>
-			<url>http://120.25.151.99:1888/repository/crbank-host/</url>
-			<releases>
-				<enabled>true</enabled>
-			</releases>
-			<snapshots>
-				<enabled>false</enabled>
-			</snapshots>
-		</repository>
-	</repositories>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+
+        <!--		<dependency>-->
+        <!--			<groupId>org.projectlombok</groupId>-->
+        <!--			<artifactId>lombok</artifactId>-->
+        <!--			<optional>true</optional>-->
+        <!--		</dependency>-->
+        <!--		<dependency>-->
+        <!--			<groupId>org.springframework.boot</groupId>-->
+        <!--			<artifactId>spring-boot-starter-test</artifactId>-->
+        <!--			<scope>test</scope>-->
+        <!--		</dependency>-->
+        <!--elasticsearch-->
+        <dependency>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>elasticsearch</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-high-level-client</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-client</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <!-- 七牛云 -->
+        <dependency>
+            <groupId>com.qiniu</groupId>
+            <artifactId>qiniu-java-sdk</artifactId>
+            <version>7.13.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+
+        <!-- amazon ses -->
+        <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
+<!--        <dependency>-->
+<!--            <groupId>com.amazonaws</groupId>-->
+<!--            <artifactId>aws-java-sdk</artifactId>-->
+<!--            <version>1.10.77</version>-->
+<!--        </dependency>-->
+
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                    <include>**/*.*</include>
+                </includes>
+                <!-- 是否替换资源中的属性 -->
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.*</include>
+                </includes>
+                <!-- 是否替换资源中的属性 -->
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <layout>ZIP</layout>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <repositories>
+        <!-- 个推 -->
+        <repository>
+            <id>getui-nexus</id>
+            <url>http://mvn.gt.igexin.com/nexus/content/repositories/releases/</url>
+        </repository>
+        <repository>
+            <id>nexus</id>
+            <url>http://120.25.151.99:1888/repository/crbank-host/</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
 
 
 </project>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
src/main/java/com/szwl/aspect/MyWebMvcConfigurer.java


+ 60 - 0
src/main/java/com/szwl/constant/ConfigConsts.java

@@ -25,4 +25,64 @@ public class ConfigConsts {
     public static final String QINIU_CLOUD_BUCKET = "videomanage";
 
     public static final String DOMAIN_OF_BUCKET = "http://qiniuyun.sunzee.com.cn/";
+
+    /**
+     * 申泽商户公众账号ID
+     */
+    public static final String SZ_WX_SUB_APP_ID = "wxcd5b1b2636c9f611";
+
+    /**
+     * 七云商户公众账号ID
+     */
+    public static final String SC_WX_SUB_APP_ID = "wxd9c7c138a055ee66";
+
+    /**
+     * 申泽商户公众账号密钥
+     */
+    public static final String SZ_WX_APP_SECRET = "e2854aa99f8279f33b4f065b2ffb75b1";
+
+    /**
+     * 七云商户公众账号密钥
+     */
+    public static final String SC_WX_APP_SECRET = "f131c85c06a80e466bd7e366cd477b93";
+
+    /**
+     * 申泽商户异常离线模板ID
+     */
+    public static final String SZ_TEMPLATE_ID = "4h0WwP60QR_6nzhkhEJTcYJHeZApCwxGYggKUNProW4";
+
+    /**
+     * 七云商户异常离线模板ID
+     */
+    public static final String SC_TEMPLATE_ID = "ilJA4oCUn_4ffPzS0PrWFKnNS7UX_j-PxjkNqLwYaCw";
+
+    /**
+     * 申泽商户设备上线模板ID
+     */
+    public static final String SZ_ON_TEMPLATE_ID = "zvBdwEQbFjnIve6WgwHCzWyGVQ-wtznwSnxfuZjnf18";
+
+    /**
+     * 申泽商户设备离线模板ID
+     */
+    public static final String SZ_OFF_TEMPLATE_ID = "hJVBzuJjVY8HWhG0Un71ciXaSBr-uSS_CzmRqwMLgM8";
+
+    /**
+     * 七云商户设备上线模板ID
+     */
+    public static final String SC_ON_TEMPLATE_ID = "vSzTge9ILaylD0F1Zr1Gec4Sf2hxHZpMg7oVwmt9iFs";
+
+    /**
+     * 七云商户设备离线模板ID
+     */
+    public static final String SC_OFF_TEMPLATE_ID = "q0POCOXjIPN8JB8nkh10Fqd5PKxqfQqHOszwvAkbJEw";
+
+    /**
+     *
+     */
+    public static final String SZ_RETURN_URL = "http://szwlh.sunzee.com.cn";
+
+    /**
+     *
+     */
+    public static final String SC_RETURN_URL = "http://sevencloud.com.cn";
 }

+ 2 - 1
src/main/java/com/szwl/controller/ADIndexController.java

@@ -41,7 +41,8 @@ public class ADIndexController {
 
     @Autowired
     private TEquipmentService equipmentService;
-    @Resource
+
+    @Autowired
     private RedisTemplate redisTemplate;
     /**
      * 根据广告id获取广告

+ 64 - 33
src/main/java/com/szwl/controller/AlarmRecordIndexController.java

@@ -6,13 +6,16 @@ import com.szwl.model.dto.AlarmRecordVo;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TAlarmRecord;
 import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TWechat;
 import com.szwl.model.utils.MailUtil;
 import com.szwl.model.utils.YunPianSms;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TAlarmRecordService;
 import com.szwl.service.TEquipmentService;
+import com.szwl.service.TWechatService;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
@@ -34,7 +37,14 @@ public class AlarmRecordIndexController {
     @Autowired
     private TAdminService adminService;
 
+    @Autowired
+    private StringRedisTemplate redisTemplate;
+
+    @Resource
+    TWechatService wechatService;
+
     private static final String appid = "07784f5fedb508046c841b391005b7de";
+
     /**
      * 添加报警记录
      */
@@ -47,7 +57,7 @@ public class AlarmRecordIndexController {
 
         String clientId = alarmRecordVo.getClientId();
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> list = equipmentService.list(query);
         TEquipment equipment = list.get(0);
         if (equipment == null) {
@@ -57,6 +67,9 @@ public class AlarmRecordIndexController {
         Long adminId = equipment.getAdminId();
         Long equipmentId = equipment.getId();
         String name = equipment.getName();
+        if (StringUtils.isEmpty(name)) {
+            name = clientId.substring(clientId.length() - 6);
+        }
         String adminUserName = equipment.getAdminUserName();
         alarmRecord.setEquipmentId(equipmentId);
         alarmRecord.setName(name);
@@ -77,41 +90,60 @@ public class AlarmRecordIndexController {
         String email = admin.getEmail();
         String ifForeign = admin.getIfForeign();
         String companyType = admin.getCompanyType();
-        if(ifForeign.equals("1")){
-            if(email!=null){
-                String subject = "Error message from Magic Candy Machine";
-                StringBuffer contnet = new StringBuffer();
-                String str1="Dear customer<br>" +
-                        "<br>" +
-                        "This is an automatic-sent mail to inform you that there is an error occurred on one of your Magic Candy machines, please kindly check the detail as below.<br>" +
-                        "<br>" +
-                        " Machine name:";
-                String str2="<br>" +" Time&Date:";
-                String str3="<br>"+" Error Message:";
-                String str4= "<br>" +" <br>You don't have to reply this mail . What you need to do is to follow the instructions on the touch screen to clear the error and recover the machine. If there is any question or more information you need . Please do not be hesitated to contact your distributor.<br>" +
-                        "<br>" +
-                        " Thank you for choosing our machine!<br>" +
-                        "<br>" +
-                        "<br>" +
-                        "Best Regards.<br>" +
-                        "Magic Candy Service Team";
-                contnet.append(str1).append(name).append(str2).append(alarmRecordVo.getOccurrenceTime()).append(str3).append(alarmContent).append(str4);
-                new MailUtil().send(email,subject,contnet.toString());
+        String messageReceiver = equipment.getMessageReceiver();
+        // 查询是否绑定微信
+        LambdaQueryWrapper<TWechat> wechatQuery = Wrappers.lambdaQuery();
+        wechatQuery.eq(TWechat::getAdminId, admin.getId());
+        TWechat wechat = wechatService.getOne(wechatQuery);
+        // 微信公众号推送
+        if(wechat != null) {
+            String sendContent = alarmContent;
+            if (sendContent.length() > 20) {
+                // 如果超过20个字符
+                sendContent =  sendContent.substring(0, 16) + "...";
+            }
+            wechatService.sendAlarmMessage(wechat.getOpenId(), clientId, name, companyType, sendContent, alarmRecordVo.getOccurrenceTime());
+        }
+        if (ifForeign.equals("1")) {
+            String subject = "Error message from Magic Candy Machine";
+            StringBuffer contnet = new StringBuffer();
+            String str1 = "Dear customer<br>" +
+                    "<br>" +
+                    "This is an automatic-sent mail to inform you that there is an error occurred on one of your Magic Candy machines, please kindly check the detail as below.<br>" +
+                    "<br>" +
+                    " Machine name:";
+            String str2 = "<br>" + " Time&Date:";
+            String str3 = "<br>" + " Error Message:";
+            String str4 = "<br>" + " <br>You don't have to reply this mail . What you need to do is to follow the instructions on the touch screen to clear the error and recover the machine. If there is any question or more information you need . Please do not be hesitated to contact your distributor.<br>" +
+                    "<br>" +
+                    " Thank you for choosing our machine!<br>" +
+                    "<br>" +
+                    "<br>" +
+                    "Best Regards.<br>" +
+                    "Magic Candy Service Team";
+            contnet.append(str1).append(name).append(str2).append(alarmRecordVo.getOccurrenceTime()).append(str3).append(alarmContent).append(str4);
+            if (StringUtils.isNotEmpty(messageReceiver)) {
+                String[] split = messageReceiver.split(",");
+                for (String s : split) {
+                    new MailUtil().send(s, subject, contnet.toString());
+                }
                 return "报警记录添加成功";
-            }else {
-                return "email is null";
+            } else {
+                if (email != null) {
+                    new MailUtil().send(email, subject, contnet.toString());
+                    return "报警记录添加成功";
+                } else {
+                    return "email is null";
+                }
             }
         }
         String result = null;
         try {
-            String messageReceiver = equipment.getMessageReceiver();
             if (!"二次曲棍".equals(alarmContent)) {
                 if (StringUtils.isNotEmpty(messageReceiver)) {
                     String[] split = messageReceiver.split(",");
                     for (int i = 0; i < split.length; i++) {
                         if (StringUtils.isNotEmpty(split[i])) {
-//                            Long id = alarmRecord.getId();
-//                            String mess = ";序号:"+String.valueOf(id);
                             if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
                                 // 如果是七云科技的用户
                                 result = YunPianSms.sendSms(appid, getSCMessage(alarmContent, name, clientId.substring(clientId.length() - 6)), split[i]);
@@ -128,7 +160,6 @@ public class AlarmRecordIndexController {
         }
         return "报警记录添加成功";
     }
-
     private String getMessage(String content, String name, String clientId) {
         String message = "【申泽智能】您好,机器" + content + ",机器名:" + name + ",设备号:" + clientId;
         return message;
@@ -158,16 +189,16 @@ public class AlarmRecordIndexController {
      */
     @GetMapping(value = "/alarmDate", produces = "text/html;charset=utf-8")
     @ResponseBody
-    public String endDate(String clientId){
+    public String endDate(String clientId) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> list = equipmentService.list(query);
         TEquipment equipment = list.get(0);
         Date endDate = equipment.getEndDate();
         long endDateTime = endDate.getTime();
         long time = System.currentTimeMillis();
-        if(endDateTime>time){
-            if(endDateTime-time<=3*24*3600*1000L){
+        if (endDateTime > time) {
+            if (endDateTime - time <= 3 * 24 * 3600 * 1000L) {
                 //发短信
                 String result = null;
                 try {
@@ -184,7 +215,7 @@ public class AlarmRecordIndexController {
 //                    logger.info("短信发送结果:" + result);
                 }
             }
-        }else{
+        } else {
 //            return JsonMessage.success("已过期");
             return "已过期";
         }
@@ -201,7 +232,7 @@ public class AlarmRecordIndexController {
      */
     @GetMapping(value = "/eliminate.htm", produces = "text/html;charset=utf-8")
     @ResponseBody
-    public String eliminate(String id){
+    public String eliminate(String id) {
         TAlarmRecord alarmRecord = alarmRecordService.getById(Long.valueOf(id));
         alarmRecord.setIsEliminate(1);
         alarmRecordService.updateById(alarmRecord);

+ 169 - 154
src/main/java/com/szwl/controller/IndexController.java

@@ -52,6 +52,8 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import static com.szwl.util.geoCoderUtil.getLocByLonLatVer;
+
 
 @Api(value = "/indexController", tags = {"设备信息上传接口"})
 @RestController
@@ -97,6 +99,9 @@ public class IndexController {
     @Autowired
     private AmqpAdmin amqpAdmin;
 
+    @Autowired
+    TWechatService wechatService;
+
     @Resource
     TLocationCheckService locationCheckService;
 
@@ -131,46 +136,46 @@ public class IndexController {
         //有记录,则进行修改
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
         query.eq(TEquipment::getClientId, clientId);
-        TEquipment _new = equipmentService.getOne(query);
-        if (_new != null) {
-            _new.setNetWorkingMode(netWorkingMode);
+        TEquipment newEquipment = equipmentService.getOne(query);
+        if (newEquipment != null) {
+            newEquipment.setNetWorkingMode(netWorkingMode);
             if (StringUtils.isNotEmpty(cabinetTm)) {
-                _new.setCabinetTm(cabinetTm);
+                newEquipment.setCabinetTm(cabinetTm);
             }
             if (StringUtils.isNotEmpty(cabinetHd)) {
-                _new.setCabinetHd(cabinetHd);
+                newEquipment.setCabinetHd(cabinetHd);
             }
             if (StringUtils.isNotEmpty(furnaceSp)) {
-                _new.setFurnaceSp(furnaceSp);
+                newEquipment.setFurnaceSp(furnaceSp);
             }
             if (StringUtils.isNotEmpty(furnaceTm)) {
-                _new.setFurnaceTm(furnaceTm);
+                newEquipment.setFurnaceTm(furnaceTm);
             }
-            _new.setLastUpdateTime(lastUpdateTime);
-//            _new.setLongitude(longitude);
+            newEquipment.setLastUpdateTime(lastUpdateTime);
+//            newEquipment.setLongitude(longitude);
             if (eqeStatus != null) {
-                _new.setEqeStatus(eqeStatus);
+                newEquipment.setEqeStatus(eqeStatus);
             }
             if (is_sleep != null) {
-                _new.setIsSleep(is_sleep);
+                newEquipment.setIsSleep(is_sleep);
             }
             if (!StringUtils.isEmpty(furnaceTm)) {
                 int fur = Integer.parseInt(furnaceTm);
-                if (_new.getEqeStatus() == 0 && fur > 150) {
-                    _new.setEqeStatus(1);
+                if (newEquipment.getEqeStatus() == 0 && fur > 150) {
+                    newEquipment.setEqeStatus(1);
                 }
-                if (_new.getEqeStatus() == null && fur > 150) {
-                    _new.setEqeStatus(1);
+                if (newEquipment.getEqeStatus() == null && fur > 150) {
+                    newEquipment.setEqeStatus(1);
                 }
             }
             if (!StringUtils.isEmpty(volume)) {
-                _new.setVolume(volume);
+                newEquipment.setVolume(volume);
             }
-//            _new.setLatitude(latitude);
-            _new.setGtClientId(gtClientId);
-            _new.setModifyDate(new Date());
-            equipmentService.updateById(_new);
-            TEquipmentDesc equipmentDesc = equipmentDescService.getById(_new.getId());
+//            newEquipment.setLatitude(latitude);
+            newEquipment.setGtClientId(gtClientId);
+            newEquipment.setModifyDate(new Date());
+            equipmentService.updateById(newEquipment);
+            TEquipmentDesc equipmentDesc = equipmentDescService.getById(newEquipment.getId());
             if (StringUtils.isNotEmpty(equipmentVo.getBlueSugar())) {
                 equipmentDesc.setBlueSugar(equipmentVo.getBlueSugar());
             }
@@ -192,15 +197,31 @@ public class IndexController {
             if (StringUtils.isNotEmpty(equipmentVo.getStick())) {
                 equipmentDesc.setStick(equipmentVo.getStick());
             }
-            if (equipmentVo.getCupQuantity() != null) {
-                equipmentDesc.setCupQuantity(equipmentVo.getCupQuantity());
-            }
-            if (StringUtils.isNotEmpty(equipmentVo.getStirTm())) {
-                equipmentDesc.setStirTm(equipmentVo.getStirTm());
-            }
-            if (StringUtils.isNotEmpty(equipmentVo.getCornGeneratorTm())) {
-                equipmentDesc.setCornGeneratorTm(equipmentVo.getCornGeneratorTm());
+            // 如果是爆米花机
+            String machineType = newEquipment.getMachineType();
+            if(StringUtils.isNotEmpty(machineType) && newEquipment.getMachineType().equals("1")) {
+                // 爆米花机搅拌温度
+                if (StringUtils.isNotEmpty(cabinetTm)) {
+                    equipmentDesc.setStirTm(cabinetTm);
+                }
+                // 爆米花机玉米发生器温度
+                if (StringUtils.isNotEmpty(cabinetHd)) {
+                    equipmentDesc.setCornGeneratorTm(cabinetHd);
+                }
+                // 爆米花机杯子剩余量
+                if (StringUtils.isNotEmpty(furnaceTm)) {
+                    equipmentDesc.setCupQuantity(Long.parseLong(furnaceTm));
+                }
             }
+//            if (equipmentVo.getCupQuantity() != null) {
+//                equipmentDesc.setCupQuantity(equipmentVo.getCupQuantity());
+//            }
+//            if (StringUtils.isNotEmpty(equipmentVo.getStirTm())) {
+//                equipmentDesc.setStirTm(equipmentVo.getStirTm());
+//            }
+//            if (StringUtils.isNotEmpty(equipmentVo.getCornGeneratorTm())) {
+//                equipmentDesc.setCornGeneratorTm(equipmentVo.getCornGeneratorTm());
+//            }
             if (StringUtils.isNotEmpty(numberOne)) {
                 equipmentDesc.setNumberOne(numberOne);
             }
@@ -226,8 +247,8 @@ public class IndexController {
     @RequestMapping(value = "/initNew2.htm", method = RequestMethod.POST, produces = "text/html;charset=utf-8")
     @ResponseBody
     public String initNew2(String clientId, String managerId, String gtClientId, String equipmentType, String ip, String longitude, String latitude) throws IOException {
-        if (StringUtils.isEmpty(ip) || StringUtils.isEmpty(clientId)) {
-            return "ip、clientId不能为空";
+        if (StringUtils.isEmpty(clientId) || StringUtils.isEmpty(longitude) || StringUtils.isEmpty(latitude)) {
+            return "设备编号、经纬度不能为空";
         }
 
         // 根据 clientId 查设备的 location,country
@@ -243,10 +264,20 @@ public class IndexController {
         double lat = Double.parseDouble(latitude);
 
         // 经度范围在73至135之间,纬度范围在3至53之间,即国内区域
-        if (!(lon >= 73) || !(lon <= 135) || !(lat >= 3) || !(lat <= 53)) {
-            // 根据ip校验位置信息
-            String addr = WhoIsUtil.getLocByIp(ip);
+        // 经度:73~124,纬度17~47,经度排除韩国,纬度排除俄罗斯,海南以南
+        if (!(lon >= 73) || !(lon <= 124) || !(lat >= 17) || !(lat <= 47)) {
+            // 根据 ip 校验位置信息
+//            String addr = WhoIsUtil.getLocByIp(ip);
+            // 根据 longitude, latitude 校验位置信息
+            String addr = null;
+            try {
+                addr = getLocByLonLatVer(longitude, latitude);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
             locationCheck.setIp(ip);
+            locationCheck.setLongitude(longitude);
+            locationCheck.setLatitude(latitude);
             locationCheck.setAddr(addr);
             locationCheckService.saveOrUpdate(locationCheck);
 
@@ -254,66 +285,8 @@ public class IndexController {
             if (checkResult.equals("fail")) {
                 return "位置不匹配,请联系营销经理/售后处理";
             }
-
         }
         return this.initNew(clientId, managerId, gtClientId, equipmentType);
-
-//        ObjectMapper objectMapper = new ObjectMapper();
-//        JsonNode jsonNode = objectMapper.readTree(s);
-//        String pro = jsonNode.get("pro").asText();
-//        String proCode = jsonNode.get("proCode").asText();
-//        String city = jsonNode.get("city").asText();
-//        String cityCode = jsonNode.get("cityCode").asText();
-//        String region = jsonNode.get("region").asText();
-//        String regionCode = jsonNode.get("regionCode").asText();
-//        String regionNames = jsonNode.get("regionNames").asText();
-//        String addr = jsonNode.get("addr").asText();
-//        String err = jsonNode.get("err").asText();
-
-
-//        locationCheck.setPro(pro);
-//        locationCheck.setProCode(proCode);
-//        locationCheck.setCity(city);
-//        locationCheck.setCityCode(cityCode);
-//        locationCheck.setRegion(region);
-//        locationCheck.setRegionCode(regionCode);
-//        locationCheck.setRegionNames(regionNames);
-
-//        locationCheck.setErr(err);
-
-//        String location = locationCheck.getLocation();
-//        String country = locationCheck.getCountry();
-
-//        boolean containsUserInput = false;
-//        if (StringUtils.isEmpty(location)) {
-//            // 只需要判断 pro,city,region,addr中是否包含 country
-//            if (StringUtils.isNotEmpty(pro) && pro.contains(country)) {
-//                containsUserInput = true;
-//            } else if (StringUtils.isNotEmpty(city) && city.contains(country)) {
-//                containsUserInput = true;
-//            } else if (StringUtils.isNotEmpty(region) && region.contains(country)) {
-//                containsUserInput = true;
-//            } else if (StringUtils.isNotEmpty(addr) && addr.contains(country)) {
-//                containsUserInput = true;
-//            }
-//        }
-        // 判断 pro,city,region,addr中是否包含 country 或 location
-
-
-//        boolean containsUserInput = true;
-//        if (StringUtils.isEmpty(location)) {
-//            containsUserInput = addr.contains(country);
-//        } else {
-//            containsUserInput = addr.contains(country) || addr.contains(location);
-//        }
-//
-//        String phone = "18620242721";
-//        String messages = "【申泽部门】设备编号:" + clientId + ",所在ip与设定位置不符,请及时查看。";
-//        if (!containsUserInput) { // 不包含,发短信通知,并拒绝审核
-//            YunPianSms.sendSms(appid, messages, phone);
-//            return "位置不匹配,请联系售后或营销经理处理";
-//        }
-
     }
 
 
@@ -546,6 +519,7 @@ public class IndexController {
                             equipment.setChannel("1");
                             equipment.setProductTotal(0);
                             equipment.setCompanyType(companyType);
+                            equipment.setMachineType(machineType);
                             //设置默认规则
                             equipment.setTimeRuleId(Long.valueOf(1));
                             if (equimentType.equals("MG320-1")) {
@@ -600,26 +574,26 @@ public class IndexController {
                         LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
                         queryProduct.eq(TProduct::getEquipmentId, equipment.getId());
                         List<TProduct> productList = productService.list(queryProduct);
-                        if (productList.size() > 0) {
-                            for (TProduct product : productList) {
-                                productService.removeById(product.getId());
-                            }
-                        }
-                        if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
-                            if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG280")) {
-                                saveProductMG280(equipmentId);
-                            } else if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG320-1")) {
-                                saveProductMG1(equipmentId);
-                            } else {
-                                saveProduct(equipmentId);
-                            }
-                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
-                            if (equimentType.equals("P30")) {
-                                saveProductP30(equipmentId);
-                            }
-                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
-                            if (equimentType.equals("SI320")) {
-                                saveProductSI320(equipmentId);
+                        if (productList.size() == 0) {
+//                            for (TProduct product : productList) {
+//                                productService.removeById(product.getId());
+//                            }
+                            if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
+                                if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG280")) {
+                                    saveProductMG280(equipmentId);
+                                } else if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG320-1")) {
+                                    saveProductMG1(equipmentId);
+                                } else {
+                                    saveProduct(equipmentId);
+                                }
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                                if (equimentType.equals("P30")) {
+                                    saveGoodsData(equipmentId, machineType, 6);
+                                }
+                            } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                                if (equimentType.equals("SI320")) {
+                                    saveGoodsData(equipmentId, machineType, 6);
+                                }
                             }
                         }
 
@@ -700,7 +674,7 @@ public class IndexController {
      * @param machineType
      * @param number
      */
-    private void saveProduct(Long id, String machineType, Integer number) {
+    private void saveGoodsData(Long id, String machineType, Integer number) {
         LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(TGoodsData::getNumber, number);
         wrapper.eq(TGoodsData::getMachineType, machineType);
@@ -716,8 +690,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }
@@ -739,8 +713,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -757,8 +731,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -778,8 +752,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -796,8 +770,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }
@@ -814,8 +788,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -833,8 +807,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -854,8 +828,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
 
@@ -877,8 +851,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }
@@ -889,7 +863,12 @@ public class IndexController {
      * @param id
      */
     private void saveProductSI320(Long id) {
-        String[] str = {"雪糕-I01", "果酱(1)-J01", "果酱(2)-J02", "果酱(3)-J03", "果碎(1)-C01", "果碎(2)-C02"};
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, 6);
+        wrapper.eq(TGoodsData::getMachineType, "2");
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
 
         for (int i = 0; i < str.length; i++) {
             TProduct product = new TProduct();
@@ -899,8 +878,8 @@ public class IndexController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }
@@ -982,7 +961,7 @@ public class IndexController {
                 machineType = "0";
             }
             //创建花型
-            saveProduct(id, machineType, Integer.parseInt(number));
+            saveGoodsData(id, machineType, Integer.parseInt(number));
 //            if (number.equals("18")) {
 //                saveProduct(id);
 //            }
@@ -1468,9 +1447,33 @@ public class IndexController {
         if (equipment == null) {
             return "该设备不存在";
         }
+        // 设备名称
+        String name = equipment.getName();
+        // 如果为空就拿设备编号后六位
+        if(StringUtils.isEmpty(name)) {
+            name = equipment.getClientId().substring(equipment.getClientId().length() - 6);
+        }
         if (eqeStatus != null) {
             equipment.setNetwork(netTime);
             equipment.setEqeStatus(eqeStatus);
+            // 查询是否有绑定微信
+            LambdaQueryWrapper<TWechat> wechatQuery = Wrappers.lambdaQuery();
+            wechatQuery.eq(TWechat::getAdminId, equipment.getAdminId());
+            TWechat wechat = wechatService.getOne(wechatQuery);
+            // 如果有绑定微信
+            if (wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
+                // 发送模板消息
+                TAdmin admin = adminService.getById(equipment.getAdminId());
+                // 查询是申泽还是七云的
+                String companyType = admin.getCompanyType();
+                wechatService.sendOnOffMessage(wechat.getOpenId(), equipment.getClientId(), netTime, companyType, name, eqeStatus);
+            }
+            if (eqeStatus == 0) {
+                equipment.setCabinetTm("");
+                equipment.setCabinetHd("");
+                equipment.setFurnaceTm("");
+                equipment.setFurnaceSp("");
+            }
             equipmentService.updateById(equipment);
         }
         return "修改成功";
@@ -2311,32 +2314,44 @@ public class IndexController {
                 return "fail";
             }
             TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
-            if (equipmentDesc.getLanguage() == null || !(equipmentDesc.getLanguage().equals(language))) {
-                equipmentDesc.setLanguage(language);
-                equipmentDescService.updateById(equipmentDesc);
-                LambdaQueryWrapper<TProduct> wrapper = Wrappers.lambdaQuery();
-                wrapper.eq(TProduct::getEquipmentId, equipment.getId());
-                List<TProduct> products = productService.list(wrapper);
-                for (TProduct product : products) {
-                    String no = product.getNo();
-                    // 如果没改过名才更改
-                    if (StringUtils.isEmpty(product.getName())) {
-                        LambdaQueryWrapper<TNameDictionary> lambdaQueryWrapper = Wrappers.lambdaQuery();
-                        lambdaQueryWrapper.eq(TNameDictionary::getLanguage, language);
-                        lambdaQueryWrapper.eq(TNameDictionary::getNo, no);
-                        TNameDictionary nameDictionary = nameDictionaryService.getOne(lambdaQueryWrapper);
-                        if (nameDictionary != null) {
-                            product.setModifyDate(new Date());
-                            product.setProductName(nameDictionary.getName());
-                            productService.updateById(product);
-                        }
+            equipmentDesc.setLanguage(language);
+            equipmentDescService.updateById(equipmentDesc);
+            LambdaQueryWrapper<TProduct> wrapper = Wrappers.lambdaQuery();
+            wrapper.eq(TProduct::getEquipmentId, equipment.getId());
+            List<TProduct> products = productService.list(wrapper);
+            for (TProduct product : products) {
+                String no = product.getNo();
+                // 如果没改过名才更改
+                if (StringUtils.isEmpty(product.getName())) {
+                    LambdaQueryWrapper<TNameDictionary> lambdaQueryWrapper = Wrappers.lambdaQuery();
+                    lambdaQueryWrapper.eq(TNameDictionary::getLanguage, language);
+                    lambdaQueryWrapper.eq(TNameDictionary::getNo, no);
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(lambdaQueryWrapper);
+                    if (nameDictionary != null) {
+                        product.setModifyDate(new Date());
+                        product.setProductName(nameDictionary.getName());
+                        productService.updateById(product);
                     }
                 }
             }
+//            if (equipmentDesc.getLanguage() == null || !(equipmentDesc.getLanguage().equals(language))) {
+//            }
             return "success";
         }
         return "fail";
     }
 
+    /**
+     * 获取DIY使用密码
+     * @return
+     */
+    @RequestMapping(value = "/getDIYPassword", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
+    @ResponseBody
+    public String getDIYPassword() {
+        TAdmin admin = adminService.getById(1L);
+        String diyPassword = admin.getDiyPassword();
+        return diyPassword;
+    }
+
 }
 

+ 47 - 14
src/main/java/com/szwl/controller/ScheduledService.java

@@ -1,18 +1,10 @@
 package com.szwl.controller;
 
-import cn.hutool.http.HttpUtil;
 import com.szwl.mapper.TLocationCheckMapper;
-import com.szwl.model.entity.TEquipment;
-import com.szwl.model.entity.THotUpdate;
 import com.szwl.model.entity.TLocationCheck;
-import com.szwl.service.TDepartmentService;
-import com.szwl.service.TEquipmentService;
-import com.szwl.service.THotUpdateService;
-import com.szwl.service.TLocationCheckService;
+import com.szwl.service.*;
 import com.szwl.service.es.EsTCoinOrderService;
 import com.szwl.service.es.EsTOrderService;
-import com.szwl.util.WhoIsUtil;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
@@ -25,46 +17,68 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Calendar;
 import java.util.List;
-import java.util.stream.Collectors;
+
 
 
 @Configuration //1.主要用于标记配置类,兼备Component的效果。
 @Component
 @EnableScheduling // 2.开启定时任务
 public class ScheduledService {
+
     @Autowired
     private TDepartmentService tDepartmentService;
+
     @Autowired
     EsTCoinOrderService esTCoinOrderService;
+
     @Autowired
     EsTOrderService esTOrderService;
+
     @Autowired
     THotUpdateService hotUpdateService;
+
     @Autowired
     TEquipmentService equipmentService;
 
     @Resource
     TLocationCheckMapper locationCheckMapper;
+
     @Resource
     TLocationCheckService locationCheckService;
 
+    @Resource
+    TWechatService wechatService;
+
     // 每周二上午8点10分去校验设备位置
     @Scheduled(cron = "0 10 8 ? * TUE")
     public void equipmentLocCheck() throws IOException {
         if (isDo()) {
-            List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullIp();
+//            List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullIp();
+            List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullAddr();
 //            String locErrorEq = null;
             StringBuilder locErrorEq = new StringBuilder();
             for (TLocationCheck locationChc : locationChecks) {
                 String clientId = locationChc.getClientId();
-                String ip = locationChc.getIp();
-                String addr = WhoIsUtil.getLocByIp(ip);
+                String addr = locationChc.getAddr();
+
                 // 这里不需要更新ip,只需要校验有ip的设备位置对不对
 //                locationCheckService.locCheckMsg(locationChc, clientId, addr);
                 String check = locationCheckService.schLocCheck(locationChc, clientId, addr);
                 locErrorEq.append(check);
             }
-            locationCheckService.schSendMsg(locErrorEq.toString());
+            if (!locErrorEq.toString().isEmpty()) {
+                locationCheckService.schSendMsg(locErrorEq.toString());
+            }
+
+//            Optional.ofNullable(locErrorEq)
+//                    .filter(stringBuilder -> stringBuilder.length() > 0)
+//                    .ifPresent(stringBuilder -> {
+//                        try {
+//                            locationCheckService.schSendMsg(locErrorEq.toString());
+//                        } catch (IOException e) {
+//                            throw new RuntimeException(e);
+//                        }
+//                    });
         }
     }
 
@@ -129,4 +143,23 @@ public class ScheduledService {
             }
         }
     }
+
+    // 设备状态检测
+    @Scheduled(cron = "0 */30 * * * ?")
+    public void checkEquipmentStatus() {
+        if (isDo()) {
+            equipmentService.checkEquipmentStatus();
+        }
+    }
+
+    /**
+     *  定时更新access_token
+     */
+    @Scheduled(cron = "0 20 * * * ?")
+    public void updateAccessToken() {
+        if (isDo()) {
+            wechatService.getAccessToken("0");
+            wechatService.getAccessToken("1");
+        }
+    }
 }

+ 29 - 2
src/main/java/com/szwl/controller/TAdminController.java

@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
@@ -71,6 +72,9 @@ public class TAdminController {
 
     PayFeign payFeign;
 
+    @Autowired
+    TWechatService wechatService;
+
     public TAdminController(SysRoleService sysRoleService, SysUserRoleService sysUserRoleService, TokenManager tokenManager, TAdminService tAdminService, TAdminEquipmentService tAdminEquipmentService, TMessageCodeService tMessageCodeService, TAirwallexWalletService airwallexWalletService, PayFeign payFeign) {
         this.sysRoleService = sysRoleService;
         this.sysUserRoleService = sysUserRoleService;
@@ -719,8 +723,7 @@ public class TAdminController {
             tAdmin.setManagerId(managerId);
             tAdminService.getById(tAdmin);
         }
-        UserDetailBO userDetailBO = BeanUtil.copyProperties(tAdmin, UserDetailBO.class);
-
+        UserDetailBO userDetailBO = BeanUtil.copyProperties(tAdmin, UserDetailBO.class, "password");
         return R.ok(userDetailBO);
     }
 
@@ -845,6 +848,9 @@ public class TAdminController {
         if (StringUtils.isNotEmpty(admin.getRelationAdminId())) {
             oldAdmin.setRelationAdminId(admin.getRelationAdminId());
         }
+        if (StringUtils.isNotEmpty(admin.getIsDistribution())) {
+            oldAdmin.setIsDistribution(admin.getIsDistribution());
+        }
         oldAdmin.setModifyDate(new Date());
         tAdminService.updateById(oldAdmin);
         return R.ok(null, "修改成功");
@@ -1097,5 +1103,26 @@ public class TAdminController {
         }
         return R.ok();
     }
+
+    @ApiOperation(value = "切换订单通知开关")
+    @GetMapping("/updateOrderNotice")
+    public ResponseModel<?> updateOrderNotice(String adminId, String orderNotice) {
+        if (StringUtils.isEmpty(adminId) || StringUtils.isEmpty(orderNotice)) {
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        // 查询是否有绑定微信
+        if (orderNotice.equals("1")) {
+            LambdaQueryWrapper<TWechat> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(TWechat::getAdminId, adminId);
+            TWechat wechat = wechatService.getOne(wrapper);
+            if (wechat == null) {
+                return R.fail(ResponseCodesEnum.A0001, "请先绑定微信");
+            }
+        }
+        TAdmin admin = tAdminService.getById(adminId);
+        admin.setOrderNotice(orderNotice);
+        tAdminService.updateById(admin);
+        return R.ok();
+    }
 }
 

+ 195 - 0
src/main/java/com/szwl/controller/TAlarmCleanController.java

@@ -0,0 +1,195 @@
+package com.szwl.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.ResponseCodesEnum;
+import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TAdmin;
+import com.szwl.model.entity.TAlarmClean;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.param.AlarmCleanParam;
+import com.szwl.model.utils.YunPianSms;
+import com.szwl.service.TAdminService;
+import com.szwl.service.TAlarmCleanService;
+import com.szwl.service.TEquipmentService;
+import com.szwl.util.IDGenerator;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author wuhs
+ * @since 2024-04-26
+ */
+@RestController
+@RequestMapping("/tAlarmClean")
+public class TAlarmCleanController {
+
+    @Autowired
+    TAlarmCleanService alarmCleanService;
+
+    @Autowired
+    TEquipmentService equipmentService;
+
+    @Autowired
+    TAdminService adminService;
+
+    /**
+     * 超过7d,且做糖大于等于15个,发送提醒,重置时间和数量
+     * 超过7d, 但做糖小于15个,不发提醒,仅重置时间
+     * 不超过7d,做糖量大于等于200,发提醒,重置时间和数量
+     * 国内发短信,海外发邮件
+     */
+    @ApiOperation("清洗提醒")
+    @PostMapping("/alarmClean")
+    public ResponseModel<TAlarmClean> alarmClean(@RequestBody AlarmCleanParam params) {
+        String clientId = params.getClientId();
+        Integer makeCandyNum = params.getMakeCandyNum();
+        String isOversea = params.getIsOversea();
+
+        // 根据 clientId 查找清洗提醒信息
+        LambdaQueryWrapper<TAlarmClean> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(TAlarmClean::getClientId, clientId);
+        TAlarmClean alarmClean = alarmCleanService.getOne(queryWrapper);
+
+        Integer candyNum = null;
+        // 首次调用
+        if (Objects.isNull(alarmClean)) {
+            TAlarmClean tAlarmClean = new TAlarmClean();
+            LambdaQueryWrapper<TEquipment> qw = Wrappers.lambdaQuery();
+            qw.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = equipmentService.getOne(qw);
+            Long equipmentId = equipment.getId();
+            Long adminId = equipment.getAdminId();
+            LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
+            wrapper.eq(TAdmin::getId, adminId);
+            TAdmin admin = adminService.getOne(wrapper);
+            String phone = admin.getPhone();
+            String email = admin.getEmail();
+
+            tAlarmClean.setId(IDGenerator.commonID());
+            tAlarmClean.setClientId(clientId);
+            tAlarmClean.setEquipmentId(equipmentId);
+            tAlarmClean.setAdminId(adminId);
+            tAlarmClean.setPhone(phone);
+            tAlarmClean.setEmail(email);
+            tAlarmClean.setIsOversea(isOversea);
+            tAlarmClean.setLastSendTime(new Date());
+            tAlarmClean.setCandyNum(makeCandyNum);
+
+            alarmCleanService.save(tAlarmClean);
+        } else {
+            candyNum = alarmClean.getCandyNum();
+            candyNum += makeCandyNum;
+            alarmClean.setCandyNum(candyNum);
+
+            alarmCleanService.saveOrUpdate(alarmClean);
+        }
+
+        LambdaQueryWrapper<TAlarmClean> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TAlarmClean::getClientId, clientId);
+        TAlarmClean alarmCleanOne = alarmCleanService.getOne(wrapper);
+        Date lastSendTime = alarmCleanOne.getLastSendTime();
+        Integer candyNumNow = alarmCleanOne.getCandyNum();
+        switch (isOversea) {
+            case "0": { // 国内
+                String phone = alarmCleanOne.getPhone();
+                if (StringUtils.isEmpty(phone)) {
+                    return R.fail(ResponseCodesEnum.A0100, "手机号不存在");
+                }
+                if (moreThan7d(lastSendTime)) { // 超过7d
+                    if (candyNumNow >= 15) { // 做糖>=15个
+                        // 发送短信
+                        alarmCleanService.sendNote(phone, clientId);
+                        // 重置时间
+                        alarmCleanOne.setLastSendTime(new Date());
+                        // 清零
+                        alarmCleanOne.setCandyNum(0);
+                    } else {
+                        // 仅重置时间
+                        alarmCleanOne.setLastSendTime(new Date());
+                    }
+                    alarmCleanService.saveOrUpdate(alarmCleanOne);
+                } else { // 不超过7d
+                    if (candyNumNow >= 200) { // 做糖>=200个
+                        // 发送短信
+                        alarmCleanService.sendNote(phone, clientId);
+                        // 重置时间
+                        alarmClean.setLastSendTime(new Date());
+                        // 清零
+                        alarmClean.setCandyNum(0);
+                        alarmCleanService.saveOrUpdate(alarmCleanOne);
+                    }
+                }
+                break;
+            }
+            case "1": { // 海外
+                String email = alarmCleanOne.getEmail();
+                if (StringUtils.isEmpty(email)) {
+                    return R.fail(ResponseCodesEnum.A0001, "邮箱地址不存在");
+                }
+                if (moreThan7d(lastSendTime)) {
+                    if (candyNumNow >= 15) {
+                        // 发送邮件
+                        alarmCleanService.sendEmail(email, clientId);
+                        // 重置时间
+                        alarmCleanOne.setLastSendTime(new Date());
+                        // 清零
+                        alarmCleanOne.setCandyNum(0);
+                    } else {
+                        // 仅重置时间
+                        alarmCleanOne.setLastSendTime(new Date());
+                    }
+                    alarmCleanService.saveOrUpdate(alarmCleanOne);
+                } else { // 不超过7d
+                    if (candyNumNow >= 200) { // 做糖>=200个
+                        // 发送邮件
+                        alarmCleanService.sendEmail(email, clientId);
+                        // 重置时间
+                        alarmCleanOne.setLastSendTime(new Date());
+                        // 清零
+                        alarmCleanOne.setCandyNum(0);
+                        alarmCleanService.saveOrUpdate(alarmCleanOne);
+                    }
+                }
+                break;
+            }
+            default:
+                return R.fail(ResponseCodesEnum.A0001, "地区参数有误" + isOversea);
+        }
+
+        return R.ok();
+
+    }
+
+    /**
+     * 是否超过7天
+     */
+    public Boolean moreThan7d (Date lastSendTime) {
+
+        Date now = new Date();
+
+        // 计算两个日期之间的时间差,单位为毫秒
+        long timeDifference = now.getTime() - lastSendTime.getTime();
+
+        // 将时间差转换为小时
+        long hoursDifference = TimeUnit.HOURS.convert(timeDifference, TimeUnit.MILLISECONDS);
+
+        // 判断时间差是否大于168小时(7天)
+        return hoursDifference >= 168;
+
+    }
+}
+

+ 4 - 4
src/main/java/com/szwl/controller/TAlarmClockController.java

@@ -430,9 +430,9 @@ public class TAlarmClockController {
     private Boolean changIds(String oldEquipmentIds, String nowEquipmentIds) {
         Boolean b = true;
         String[] olds = oldEquipmentIds.split(",");
-        int[] a = new int[olds.length];
+        Long[] a = new Long[olds.length];
         for(int i=0;i<olds.length;i++){
-            a[i] = Integer.parseInt(olds[i]);
+            a[i] = Long.valueOf(olds[i]);
         }
         Arrays.sort(a);
         StringBuffer old = new StringBuffer();
@@ -440,9 +440,9 @@ public class TAlarmClockController {
             old.append(a[i]+",");
         }
         String[] newIds = nowEquipmentIds.split(",");
-        int[] c = new int[newIds.length];
+        Long[] c = new Long[newIds.length];
         for(int i=0;i<newIds.length;i++){
-            c[i] = Integer.parseInt(newIds[i]);
+            c[i] = Long.valueOf(newIds[i]);
         }
         Arrays.sort(c);
         StringBuffer now = new StringBuffer();

+ 109 - 34
src/main/java/com/szwl/controller/TEquipmentApplyController.java

@@ -19,6 +19,9 @@ import com.szwl.util.IDGenerator;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.amqp.core.AmqpAdmin;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.Queue;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -44,10 +47,13 @@ import java.util.stream.Collectors;
 @Api(value = "/tEquipmentApply", tags = {"设备连接申请表"})
 @RequestMapping("/tEquipmentApply")
 public class TEquipmentApplyController {
+
     @Autowired
     TAdminService adminService;
+
     @Autowired
     TEquipmentApplyService equipmentApplyService;
+
     @Autowired
     TEquipmentService equipmentService;
 
@@ -56,11 +62,19 @@ public class TEquipmentApplyController {
 
     @Autowired
     TProportionService proportionService;
+
     @Autowired
     TEquipmentDescService equipmentDescService;
+
     @Autowired
     EsTEquipmentService esTEquipmentService;
 
+    @Autowired
+    AmqpAdmin amqpAdmin;
+
+    @Autowired
+    TGoodsDataService goodsDataService;
+
     @ApiOperation(value = "查找机器审核列表")
     @GetMapping("/pageTEquipmentApply")
     public ResponseModel<IPage<?>> pageTEquipmentApply(String adminId, String clientId, String userName,String managerId,String statusType, long current, long size ) {
@@ -138,7 +152,7 @@ public class TEquipmentApplyController {
                         String adminUserName = equipmentApply.getAdminUserName();
                         Integer type = tAdmin.getType();
                         String gtClientId = equipmentApply.getGtClientId();
-                        String equimentType = equipmentApply.getEquimentType();
+                        String equipmentType = equipmentApply.getEquimentType();
                         String machineType = equipmentApply.getMachineType();
                         String clientId1 = equipmentApply.getClientId();
                         //判断是否已经生成
@@ -170,7 +184,7 @@ public class TEquipmentApplyController {
                             equipment.setCompanyType(companyType);
                             // 设备类型
                             equipment.setMachineType(machineType);
-                            if(equimentType.equals("MG320-1")){
+                            if(equipmentType.equals("MG320-1")){
                                 if(!equipmentApply.getEquimentType().equals(equipment.getEquimentType())&&equipment.getEquimentType().equals("MG320")){
                                     LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
                                     queryProduct.eq(TProduct::getEquipmentId,equipment.getId());
@@ -182,7 +196,7 @@ public class TEquipmentApplyController {
                                 }
                                 equipment.setEquimentType("MG320");
                             } else {
-                                equipment.setEquimentType(equimentType);
+                                equipment.setEquimentType(equipmentType);
                             }
 
                             equipmentService.updateById(equipment);
@@ -244,13 +258,13 @@ public class TEquipmentApplyController {
                         equipment.setCompanyType(companyType); // 公司平台
                         equipment.setMachineType(machineType); // 设备类型
                         //设置默认规则
-                        equipment.setTimeRuleId(Long.valueOf(1));
-                        if(equimentType.equals("MG320-1")){
+                        equipment.setTimeRuleId(1L);
+                        if(equipmentType.equals("MG320-1")){
                             equipment.setEquimentType("MG320");
                         }else {
-                            equipment.setEquimentType(equimentType);
+                            equipment.setEquimentType(equipmentType);
                         }
-                        if(!StringUtils.isEmpty(equimentType)&&equimentType.equals("MG280")){
+                        if(!StringUtils.isEmpty(equipmentType)&&equipmentType.equals("MG280")){
                             Long monthBegin = getMonthBegin(new Date());
                             long time = System.currentTimeMillis();
                             if(time<monthBegin){
@@ -275,20 +289,47 @@ public class TEquipmentApplyController {
                         }
                         //获取设备的id
                         Long equipmentId = equipment.getId();
-                        if(StringUtils.isNotEmpty(equimentType) && equimentType.equals("MG280")){
-                            saveProductMG280(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equimentType) && equimentType.equals("MG320-1")){
-                            saveProductMG1(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equimentType) && equimentType.equals("P30")){
-                            saveProductP30(equipmentId);
-                        } else if(StringUtils.isNotEmpty(equimentType) && equimentType.equals("SI320")){
-                            saveProductSI320(equipmentId);
-                        } else {
-                            saveProduct(equipmentId);
+                        if (StringUtils.isEmpty(machineType) || machineType.equals("0")) {
+                            if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG280")) {
+                                saveProductMG280(equipmentId);
+                            } else if (equipmentApply.getEquimentType() != null && equipmentApply.getEquimentType().equals("MG320-1")) {
+                                saveProductMG1(equipmentId);
+                            } else {
+                                saveProduct(equipmentId);
+                            }
+                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("1")){
+                            if (equipmentType.equals("P30")) {
+                                saveGoodsData(equipmentId, machineType, 6);
+                            }
+                        } else if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")){
+                            if (equipmentType.equals("SI320")) {
+                                saveGoodsData(equipmentId, machineType, 6);
+                            }
                         }
+//                        if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG280")){
+//                            saveProductMG280(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("MG320-1")){
+//                            saveProductMG1(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("P30")){
+//                            saveProductP30(equipmentId);
+//                        } else if(StringUtils.isNotEmpty(equipmentType) && equipmentType.equals("SI320")){
+//                            saveProductSI320(equipmentId);
+//                        } else {
+//                            saveProduct(equipmentId);
+//                        }
                         LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
                         query1.eq(TEquipment::getClientId,clientId);
                         TEquipment tEquipment = equipmentService.getOne(query1);
+                        // 删除MQ队列
+                        amqpAdmin.deleteQueue(clientId);
+                        // 重新创建队列
+                        Map<String,Object> arg = new HashMap<>();
+                        arg.put("x-message-ttl",1800000);
+                        amqpAdmin.declareQueue(new Queue(clientId, true, false, false, arg));
+                        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
+                        amqpAdmin.declareBinding(new Binding(clientId,
+                                Binding.DestinationType.QUEUE,
+                                equipmentType, clientId, objectObjectHashMap));
                         try {
                             if(tEquipment != null) {
                                 esTEquipmentService.insertData(tEquipment);
@@ -298,6 +339,7 @@ public class TEquipmentApplyController {
                         }
                         TEquipmentDesc equipmentDesc = new TEquipmentDesc();
                         equipmentDesc.setEquipmentId(tEquipment.getId());
+                        equipmentDesc.setFlowers(tEquipment.getFlowers());
                         equipmentDescService.save(equipmentDesc);
 
                     } else if (status.equals("unAgreed")) {
@@ -321,6 +363,34 @@ public class TEquipmentApplyController {
     }
 
     /**
+     * 添加商品
+     * @param id
+     * @param machineType
+     * @param number
+     */
+    private void saveGoodsData(Long id, String machineType, Integer number) {
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, number);
+        wrapper.eq(TGoodsData::getMachineType, machineType);
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
+
+        for (int i = 0; i < str.length; i++) {
+            TProduct product = new TProduct();
+            product.setCreateDate(new Date());
+            product.setModifyDate(new Date());
+            product.setEquipmentId(id);
+            String[] split = str[i].split("-");
+            product.setProductName(split[0]);
+            product.setNo(split[1]);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
+            productService.save(product);
+        }
+    }
+
+    /**
      * 添加产品
      *
      * @param id
@@ -338,8 +408,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -355,8 +425,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -375,8 +445,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -392,8 +462,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
     }
@@ -409,8 +479,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -427,8 +497,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -449,8 +519,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(1.00));
+            product.setCodePrice(new BigDecimal(1.00));
             productService.save(product);
         }
 
@@ -462,7 +532,12 @@ public class TEquipmentApplyController {
      * @param id
      */
     private void saveProductSI320(Long id) {
-        String[] str = {"雪糕-I01", "果酱(1)-J01", "果酱(2)-J02", "果酱(3)-J03", "果碎(1)-C01", "果碎(2)-C02"};
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, 6);
+        wrapper.eq(TGoodsData::getMachineType, "2");
+        TGoodsData goodsData = goodsDataService.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
 
         for (int i = 0; i < str.length; i++) {
             TProduct product = new TProduct();
@@ -472,8 +547,8 @@ public class TEquipmentApplyController {
             String[] split = str[i].split("-");
             product.setProductName(split[0]);
             product.setNo(split[1]);
-            product.setRmbPrice(BigDecimal.ZERO);
-            product.setCodePrice(BigDecimal.ZERO);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
             productService.save(product);
         }
     }

+ 131 - 73
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -3,7 +3,6 @@ package com.szwl.controller;
 
 import cn.com.crbank.ommo.bean.ResultMessage;
 import cn.com.crbank.ommo.esUtil.BeanUtils;
-//import org.apache.commons.beanutils.BeanUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,11 +19,9 @@ import com.szwl.annotation.Audit;
 import com.szwl.constant.AuditEnum;
 import com.szwl.constant.ConfigConsts;
 import com.szwl.constant.ResponseCodesEnum;
-import com.szwl.manager.TokenManager;
 import com.szwl.model.bean.*;
 import com.szwl.model.bo.R;
 import com.szwl.model.bo.ResponseModel;
-import com.szwl.model.bo.UserDetailBO;
 import com.szwl.model.entity.*;
 import com.szwl.model.param.PasswordParam;
 import com.szwl.model.query.StatisticsParam;
@@ -36,18 +33,15 @@ import com.szwl.util.DownloadUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang.StringUtils;
-import org.springframework.amqp.core.MessageProperties;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
-import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.text.ParseException;
@@ -104,9 +98,9 @@ public class TEquipmentController {
     @Autowired
     TLabelService labelService;
 
-    TokenManager tokenManager;
+//    TokenManager tokenManager;
 
-    private int j;
+//    private int j;
 
     // 超时时间为30秒
     private static final int TIMEOUT = 30000;
@@ -147,7 +141,6 @@ public class TEquipmentController {
      * @param adminName     商户的登录名
      * @param equipmentName 机器名称
      * @param areaName      地址名-fullName
-     * @return
      */
     @ApiOperation(value = "查找机器列表")
     @PostMapping("/findList")
@@ -171,6 +164,13 @@ public class TEquipmentController {
                 query.eq(TEquipment::getAdminId, id);
             }
             if (type == 3) {
+                // TODO:
+//                 查找该商家的所有子账户,一层一层寻找,一个账户只能关联一个账户,
+//                 t_admin,
+//                 parent_id 指的是子商家的上级 admin_id,
+//                 relation_id 指的是关联上级账户的 admin_id,
+//                 需要增加一个下级账户的admin_id, sub_account
+//                 child_account 孩子账户有多个,不能这样
                 //查找属于这个商家子账户的设备 todo
                 TAdminEquipment adminEquipment = tAdminEquipmentService.getById(admin.getId());
                 if (adminEquipment.getType().equals("0")) {
@@ -226,7 +226,7 @@ public class TEquipmentController {
         if (StringUtils.isNotEmpty(labelId)) {
             TLabel label = labelService.getById(labelId);
             String equipmentIds = label.getEquipmentIds();
-            equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
+            equipmentIds = equipmentIds.replace("\"", "").replace("[", "").replace("]", "");
             String[] split = equipmentIds.split(",");
             query.in(TEquipment::getId, split);
         }
@@ -571,11 +571,12 @@ public class TEquipmentController {
             if (StringUtils.isNotEmpty(oldEquipment.getFlowers()) && !oldEquipment.getFlowers().equals(equipment.getFlowers())) {
                 //发信息
                 tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("flowers", equipment.getFlowers()).toString());
+                // 通知客户
+                tEquipmentService.informClient(oldEquipment.getAdminId(), oldEquipment.getClientId());
             }
             oldEquipment.setFlowers(equipment.getFlowers());
         }
         String[] message = new String[3];
-        ;
         message[0] = equipment.getMessageReceiver1();
         message[1] = equipment.getMessageReceiver2();
         message[2] = equipment.getMessageReceiver3();
@@ -770,17 +771,17 @@ public class TEquipmentController {
 //            PushUtils.push(equipment1.getGtClientId(), "【棉花糖】设备管理-更改密码", "修改admin密码", PushUtils.buildJson("adminPwd", equipment1.getAdminPwd()).toString());
         }
         //定时开机
-        if (type == 3) {
+//        if (type == 3) {
 //            equipment1.setBootTime(equipment.getBootTime());
 //            tEquipmentService.sentMessage(equipment1.getClientId(),PushUtils.buildJson("updateBootTime", equipment.getBootTime()).toString());
 //            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateBootTime", equipment.getBootTime()).toString());
-        }
+//        }
         //定时关机
-        if (type == 4) {
+//        if (type == 4) {
 //            equipment1.setOffTime(equipment.getOffTime());
 //            tEquipmentService.sentMessage(equipment1.getClientId(), PushUtils.buildJson("updateOffTime", equipment.getBootTime()).toString());
 //            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateOffTime", equipment.getBootTime()).toString());
-        }
+//        }
         if (type == 5) {
             equipment1.setMessageReceiver(equipment.getMessageReceiver());
         }
@@ -893,8 +894,8 @@ public class TEquipmentController {
     @ApiOperation(value = "获取机器数量")
     @PostMapping("/getMachineNum")
     public ResponseModel<?> getMachineNum(@RequestBody StatisticsParam param) {
-        String machineTotalNum = "";
-        String machineUseNum = "";
+        String machineTotalNum;
+        String machineUseNum;
         String equipmentId = param.getEquipmentId();
         String paramAdminId = param.getAdminId();
         TAdmin admin = tAdminService.getById(paramAdminId);
@@ -912,7 +913,7 @@ public class TEquipmentController {
             param.setCompanyType("1");
         }
         //判断是否有机器id传入
-        if (equipmentId != null && equipmentId != "") {
+        if (equipmentId != null && !equipmentId.equals("")) {
             Long id = Long.valueOf(equipmentId);
             TEquipment equipment = tEquipmentService.getById(id);
             Long adminId = equipment.getAdminId();
@@ -934,7 +935,19 @@ public class TEquipmentController {
             param.setAdminId(String.valueOf(admin.getParentId()));
         }
         machineTotalNum = tEquipmentService.findMachineTotalNum(param);
-        machineUseNum = tEquipmentService.findMachineUseNum(param);
+//        machineUseNum = tEquipmentService.findMachineUseNum(param);
+        switch (type) {
+            case 0:
+            case 1:
+                machineUseNum = tEquipmentService.findMachineUseNumAdmin(param);
+                break;
+            case 2:
+            case 3:
+                machineUseNum = tEquipmentService.findMachineUseNum(param);
+                break;
+            default:
+                throw new IllegalArgumentException("未知等级");
+        }
         Map<String, String> map = new HashMap<>();
         map.put("machineTotalNum", machineTotalNum);
         map.put("machineUseNum", machineUseNum);
@@ -1055,7 +1068,7 @@ public class TEquipmentController {
 
     public static Long getNetworkTime() {
         Long time = null;
-        URL url = null;//取得资源对象http://time.tianqi.com/
+        URL url;//取得资源对象http://time.tianqi.com/
         try {
             url = new URL("http://time.tianqi.com");
             URLConnection uc = url.openConnection();//生成连接对象
@@ -1118,16 +1131,11 @@ public class TEquipmentController {
 
     @ApiOperation(value = "获取所有机器开关机状态")
     @PostMapping("/equipmentStatus")
-    public ResponseEntity<?> equipmentStatus(@RequestBody StatisticsParam param) {
+    public ResponseModel<?> equipmentStatus(@RequestBody StatisticsParam param) {
         String adminId = param.getAdminId();
         //碧桂园的机器太多,不查
         if (adminId.equals("236") || adminId.equals("31")) {
-            return ResponseEntity
-                    .status(HttpStatus.OK)
-                    .body(new ResultMessage()
-                            .setCode(true)
-                            .setData("SUCCESS")
-                            .setMessage("SUCCESS"));
+            return R.ok();
         }
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
         query.eq(TEquipment::getAdminId, Long.valueOf(adminId));
@@ -1138,24 +1146,23 @@ public class TEquipmentController {
 //                PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("onoffstatus", "0").toString());
             }
         }
-        return ResponseEntity
-                .status(HttpStatus.OK)
-                .body(new ResultMessage()
-                        .setCode(true)
-                        .setData("SUCCESS")
-                        .setMessage("SUCCESS"));
+        return R.ok();
     }
 
     @ApiOperation(value = "检验所有机器是否开机")
     @PostMapping("/checkEquipmentStatus")
-    public ResponseEntity<?> checkEquipmentStatus(@RequestBody StatisticsParam param) {
+    public ResponseModel<?> checkEquipmentStatus(@RequestBody StatisticsParam param) {
+        // 通过管理员ID查询所有设备
         String adminId = param.getAdminId();
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
         query.eq(TEquipment::getAdminId, Long.valueOf(adminId));
         List<TEquipment> equipmentList = tEquipmentService.list(query);
+
+        // 获取当前时间,并检查设备状态是否过期
         long nowTime = System.currentTimeMillis();
         if (equipmentList.size() > 0) {
             for (TEquipment equipment : equipmentList) {
+                // 如果设备的最后修改时间超过310秒前,则清除设备状态信息
                 long modifyTime = equipment.getModifyDate().getTime();
                 if (nowTime > modifyTime && (nowTime - modifyTime) > 310000) {
                     equipment.setCabinetTm("");
@@ -1166,12 +1173,8 @@ public class TEquipmentController {
                 }
             }
         }
-        return ResponseEntity
-                .status(HttpStatus.OK)
-                .body(new ResultMessage()
-                        .setCode(true)
-                        .setData("SUCCESS")
-                        .setMessage("SUCCESS"));
+        // 返回操作成功的响应
+        return R.ok();
     }
 
     @ApiOperation(value = "机器开关机")
@@ -1179,25 +1182,14 @@ public class TEquipmentController {
     public ResponseEntity<?> onOff(@RequestBody StatisticsParam param) {
         String equipmentId = param.getEquipmentId();
         Long id = Long.valueOf(equipmentId);
-//        TEquipment equipments = tEquipmentService.selectEntityById(id);
-//        PushUtils.push(equipments.getGtClientId(), "", "", PushUtils.buildJson("onoffstatus", "0").toString());
         TEquipment equipment = tEquipmentService.getById(id);
         if (equipment == null) {
 //			return ERROR_MESSAGE;
         }
+        String machineType = equipment.getMachineType();
         String eqeStatus = "1";
         String code = param.getEqeStatus();
         //开机为1,关机为0
-        Integer intcode = Integer.valueOf(code);
-        Integer eqeStatus1 = equipment.getEqeStatus();
-//        if(intcode==eqeStatus1){
-//            return ResponseEntity
-//                    .status(HttpStatus.OK)
-//                    .body(new ResultMessage()
-//                            .setCode(false)
-//                            .setData("ERROT")
-//                            .setMessage("操作异常"));
-//        }
         if (code.equals("0")) {
             eqeStatus = "0";
             equipment.setEqeStatus(0);
@@ -1212,11 +1204,11 @@ public class TEquipmentController {
             time = System.currentTimeMillis();
         }
         if (time != null) {
-//            System.out.println("time=="+time);
-            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("eqeStatus", eqeStatus, String.valueOf(time), "http://time.tianqi.com").toString());
-//            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("eqeStatus", eqeStatus,String.valueOf(time),"http://time.tianqi.com").toString());
-
-//            tEquipmentService.updateById(equipment);
+            if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")) {
+                tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("machineReset", "machineReset").toString());
+            } else {
+                tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("eqeStatus", eqeStatus, String.valueOf(time), "http://time.tianqi.com").toString());
+            }
         } else {
             return ResponseEntity
                     .status(HttpStatus.OK)
@@ -1370,14 +1362,14 @@ public class TEquipmentController {
                                     }
                                     StringBuffer namelast = new StringBuffer();
                                     namelast.append(cityMap.get(citykey)).append("  ");
-                                    String day = "";
-                                    String week = "";
-                                    String month = "";
-                                    String year = "";
+                                    String day;
+                                    String week;
+                                    String month;
+                                    String year;
                                     //数据为空时要处理
                                     for (int s = 1; s < 5; s++) {
-                                        String startDate = null;
-                                        String endDate = null;
+                                        String startDate;
+                                        String endDate;
                                         if (s == 1) {
                                             //日
                                             Date date = new Date();
@@ -1385,7 +1377,7 @@ public class TEquipmentController {
                                             String format = dateFormat.format(date);
                                             startDate = format;
                                             endDate = format;
-                                            Map<String, Object> params = new HashMap<String, Object>();
+                                            Map<String, Object> params = new HashMap<>();
                                             params.put("areaIds", cityIds);
                                             params.put("startDate", startDate);
                                             params.put("endDate", endDate);
@@ -1405,7 +1397,7 @@ public class TEquipmentController {
                                             Map<String, String> weekDate = getWeekDate();
                                             startDate = weekDate.get("mondayDate");
                                             endDate = weekDate.get("sundayDate");
-                                            Map<String, Object> params = new HashMap<String, Object>();
+                                            Map<String, Object> params = new HashMap<>();
                                             params.put("areaIds", cityIds);
                                             params.put("startDate", startDate);
                                             params.put("endDate", endDate);
@@ -1434,7 +1426,7 @@ public class TEquipmentController {
                                             String last = dateFormat.format(ca.getTime());
                                             startDate = first;
                                             endDate = last;
-                                            Map<String, Object> params = new HashMap<String, Object>();
+                                            Map<String, Object> params = new HashMap<>();
                                             params.put("areaIds", cityIds);
                                             params.put("startDate", startDate);
                                             params.put("endDate", endDate);
@@ -1451,7 +1443,7 @@ public class TEquipmentController {
                                         }
                                         if (s == 4) {
                                             //年
-                                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
+//                                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
                                             Calendar cale = Calendar.getInstance();
                                             int year1 = cale.get(Calendar.YEAR);
                                             String y = String.valueOf(year1);
@@ -1461,7 +1453,7 @@ public class TEquipmentController {
                                             StringBuffer e = new StringBuffer();
                                             e.append(y).append("/12/30");
                                             endDate = e.toString();
-                                            Map<String, Object> params = new HashMap<String, Object>();
+                                            Map<String, Object> params = new HashMap<>();
                                             params.put("areaIds", cityIds);
                                             params.put("startDate", startDate);
                                             params.put("endDate", endDate);
@@ -1763,61 +1755,127 @@ public class TEquipmentController {
     /**
      * 上传日志
      *
-     * @param equipmentId
-     * @param day
+     * @param equipmentId 设备ID,用于标识上传日志的设备
+     * @param day         日期,指定要上传日志的日期
+     * @return 返回操作结果,成功则返回成功信息,失败则返回失败原因
      */
     @ApiOperation(value = "上传日志")
     @GetMapping("/uploadLog")
     public ResponseModel<?> uploadLog(String equipmentId, String day) {
+        // 检查设备ID是否为空
         if (StringUtils.isEmpty(equipmentId)) {
             return R.fail(A0001);
         }
+        // 根据设备ID查询设备信息
         TEquipment tEquipment = tEquipmentService.getById(equipmentId);
+        // 检查设备信息是否存在
         if (tEquipment == null) {
             return R.fail(A0001, "该设备不存在");
         }
+        // 组装日志信息的标识
         String clientId = tEquipment.getClientId();
         String kind = day + "-" + clientId;
+        // 获取设备的渠道号和类型
         String channel = tEquipment.getChannel();
         String equimentType = tEquipment.getEquimentType();
+        // 如果渠道号为空或为"1",或设备类型为空,则使用个推推送日志
         if (StringUtils.isEmpty(channel) || channel.equals("1") || StringUtils.isEmpty(equimentType)) {
-            //用个推
             PushUtils.push(tEquipment.getGtClientId(), "", "", PushUtils.buildJson("log", kind).toString());
         }
+        // 如果渠道号为"2"且设备类型不为空,则使用MQ发送日志
         if (StringUtils.isNotEmpty(channel) && channel.equals("2") && StringUtils.isNotEmpty(equimentType)) {
-            //用Mq
             tEquipmentService.sentMessage(tEquipment.getClientId(), PushUtils.buildJson("log", kind).toString());
         }
+        // 返回操作成功信息
         return R.ok();
     }
 
+
+    /**
+     * 查询指定设备在指定日期的日志是否已上传至七牛云。
+     *
+     * @param equipmentId 设备ID,用于查询日志所属设备。
+     * @param day         日期,格式为"yyyy-MM-dd",用于指定要查询的日志日期。
+     * @return 返回一个响应模型对象,如果日志已上传则返回成功信息和日志文件名,否则返回失败信息。
+     */
     @ApiOperation(value = "查询日志是否上传成功")
     @GetMapping("/queryLog")
     public ResponseModel<?> queryLog(String equipmentId, String day) {
+        // 检查设备ID是否为空
         if (StringUtils.isEmpty(equipmentId)) {
             return R.fail(A0001);
         }
+        // 根据设备ID查询设备信息
         TEquipment tEquipment = tEquipmentService.getById(equipmentId);
         if (tEquipment == null) {
             return R.fail(A0001, "该设备不存在");
         }
+        // 根据设备ID和日期构造日志文件名
         String clientId = tEquipment.getClientId();
         String key = "log/" + day + "-" + clientId + ".txt";
-        //构造一个带指定 Region 对象的配置类
+
+        // 配置七牛云连接
         Configuration cfg = new Configuration(Region.region2());
         Auth auth = Auth.create(ConfigConsts.QINIU_CLOUD_ACCESS_KEY, ConfigConsts.QINIU_CLOUD_SECRET_KEY);
         BucketManager bucketManager = new BucketManager(auth, cfg);
+
         boolean flag = true;
         try {
+            // 尝试获取指定文件信息,判断文件是否存在
             FileInfo fileInfo = bucketManager.stat(ConfigConsts.QINIU_CLOUD_BUCKET, key);
         } catch (QiniuException ex) {
             System.err.println(ex.response.error);
             flag = false;
         }
+
+        // 根据文件是否存在返回相应结果
         if (flag) {
             return R.ok(key);
         }
         return R.fail(F0002);
     }
+
+    /**
+     * 修改DIY功能使用的密码
+     *
+     * @param diyPassword 新的DIY功能密码
+     * @return 返回操作结果,成功返回成功标志,失败返回错误代码
+     */
+    @ApiOperation(value = "修改diy功能使用密码")
+    @GetMapping("/updateDIYPassword")
+    public ResponseModel<?> updateDIYPassword(String diyPassword) {
+        // 检查传入的DIY密码是否为空
+        if (StringUtils.isEmpty(diyPassword)) {
+            return R.fail(A0001);
+        }
+        // 获取管理员对象
+        TAdmin admin = tAdminService.getById(1L);
+        // 设置新的DIY密码
+        admin.setDiyPassword(diyPassword);
+        // 更新管理员信息
+        tAdminService.updateById(admin);
+        // 返回操作成功标志
+        return R.ok();
+    }
+
+
+    @ApiOperation(value = "远程开启触摸屏")
+    @GetMapping("/openScreen")
+    public ResponseModel<?> openScreen(String equipmentId) {
+        // 检查设备ID是否为空
+        if (StringUtils.isEmpty(equipmentId)) {
+            return R.fail(A0001);
+        }
+        // 根据设备ID查询设备信息
+        TEquipment equipment = tEquipmentService.getById(equipmentId);
+        if (equipment == null) {
+            return R.fail(A0001, "该设备不存在");
+        }
+        // 远程开启触摸屏
+        String clientId = equipment.getClientId();
+        tEquipmentService.sentMessage(clientId, PushUtils.buildJson("restartAndroid", "restartAndroid").toString());
+        return R.ok();
+    }
+
 }
 

+ 6 - 20
src/main/java/com/szwl/controller/TJoinpayMchController.java

@@ -218,29 +218,15 @@ public class TJoinpayMchController {
     @GetMapping("/getMch")
     public ResponseModel<TJoinpayMch> getMch(@RequestParam String id) {
         TAdmin admin = adminService.getById(id);
-        if(!admin.getIsAdmined()){
-            if(admin.getType()<=1){
-                //公司
-                TJoinpayMch tJoinpayMch = new TJoinpayMch();
-                tJoinpayMch.setType("0");
-                return R.ok(tJoinpayMch);
-            }else {
-                //商家
-                TAdmin parentAdmin = adminService.getById(admin.getParentId());
-                LambdaQueryWrapper<TJoinpayMch> query = Wrappers.lambdaQuery();
-                query.eq(TJoinpayMch::getAdminId,Long.valueOf(parentAdmin.getId()));
-                List<TJoinpayMch> list = tJoinpayMchService.list(query);
-                TJoinpayMch tJoinpayMch = list.get(0);
-                tJoinpayMchService.refreshMch(tJoinpayMch);
-                String s = tJoinpayMchService.refreshMyAccount(tJoinpayMch);
-                TJoinpayMch joinpayMch = tJoinpayMchService.getById(tJoinpayMch.getId());
-                return R.ok(joinpayMch);
-            }
+        if(admin.getType()<=1){
+            //公司
+            TJoinpayMch tJoinpayMch = new TJoinpayMch();
+            tJoinpayMch.setType("0");
+            return R.ok(tJoinpayMch);
         }else {
+            //商家
             LambdaQueryWrapper<TJoinpayMch> query = Wrappers.lambdaQuery();
             query.eq(TJoinpayMch::getAdminId,Long.valueOf(id));
-//            List<TJoinpayMch> list = tJoinpayMchService.list(query);
-//            TJoinpayMch tJoinpayMch = list.get(0);
             TJoinpayMch tJoinpayMch = tJoinpayMchService.getOne(query);
             if(tJoinpayMch == null) {
                 return R.ok(null);

+ 14 - 40
src/main/java/com/szwl/controller/TLabelController.java

@@ -53,42 +53,6 @@ public class TLabelController {
         if(StringUtils.isNotEmpty(label.getName())&&StringUtils.isNotEmpty(label.getType())&&label.getAdminId()!=null){
             label.setCreateDate(new Date());
             label.setModifyDate(new Date());
-            List<String> ids = new ArrayList<>();
-            if(label.getType().equals("0")){
-                String adminNames = label.getAdminNames();
-                if(StringUtils.isNotEmpty(adminNames)){
-                    List<String> adminNamelist = JSON.parseArray(adminNames, String.class);
-                    for(String username:adminNamelist){
-                        LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
-                        query.like(TAdmin::getUsername,username);
-                        List<TAdmin> list = adminService.list(query);
-                        TAdmin tAdmin = list.get(0);
-                        ids.add(String.valueOf(tAdmin.getId()));
-                    }
-                }
-            }
-            if(label.getType().equals("1")){
-                String equipmentNames = label.getEquipmentNames();
-                if(StringUtils.isNotEmpty(equipmentNames)){
-                    List<String> equipmentNamelist = JSON.parseArray(equipmentNames, String.class);
-                    for(String name:equipmentNamelist){
-                        LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-                        query.like(TEquipment::getName,name);
-                        List<TEquipment> list = equipmentService.list(query);
-                        TEquipment equipment = list.get(0);
-                        ids.add(String.valueOf(equipment.getId()));
-                    }
-
-                }
-            }
-            if(ids.size()>0){
-                if(label.getType().equals("0")){
-                    label.setAdminIds(ids.toString());
-                }
-                if(label.getType().equals("1")){
-                   label.setEquipmentIds(ids.toString());
-                }
-            }
             labelService.save(label);
             return R.ok();
         }else {
@@ -111,13 +75,23 @@ public class TLabelController {
         return R.ok();
 
     }
-    @ApiOperation(value = "获取标签列表")
+    /**
+     * 获取分组列表
+     * @param adminId 管理员ID
+     * @param type 分组类型
+     * @return 分组列表
+     */
     @GetMapping("/list")
-    public ResponseModel<?> list(String adminId,String type) {
+    public ResponseModel<?> list(String adminId, String type) {
+        // 构建查询条件
         LambdaQueryWrapper<TLabel> query = Wrappers.lambdaQuery();
-        query.like(TLabel::getAdminId,adminId);
-        query.like(TLabel::getType,type);
+        query.eq(TLabel::getAdminId, adminId);
+        query.eq(TLabel::getType, type);
+
+        // 查询分组列表
         List<TLabel> list = labelService.list(query);
+
+        // 返回分组列表
         return R.ok(list);
     }
     @ApiOperation(value = "获取标签详情")

+ 48 - 35
src/main/java/com/szwl/controller/TLocationCheckController.java

@@ -2,19 +2,11 @@ package com.szwl.controller;
 
 
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.szwl.constant.ResponseCodesEnum;
 import com.szwl.model.bo.R;
 import com.szwl.model.bo.ResponseModel;
-import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TLocationCheck;
-import com.szwl.model.utils.YunPianSms;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TLocationCheckService;
 import com.szwl.util.WhoIsUtil;
@@ -22,7 +14,6 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.io.IOException;
 import java.util.*;
 
 /**
@@ -45,7 +36,7 @@ public class TLocationCheckController {
         this.adminService = adminService;
     }
 
-    @ApiOperation(value = "获取录入的位置信息")
+    @ApiOperation(value = "获取定位信息")
     @GetMapping("/getLocInfo")
     public ResponseModel<?> getLocInfo(String clientId) {
         if (StringUtils.isEmpty(clientId)) {
@@ -56,19 +47,43 @@ public class TLocationCheckController {
         lqw.eq(TLocationCheck::getClientId, clientId);
         TLocationCheck locationCheck = locationCheckService.getOne(lqw);
         if (Objects.nonNull(locationCheck)) {
+            HashMap<String, String> locationMap = new HashMap<>();
             String country = locationCheck.getCountry();
-            if (country.equals("中国")) {
-                String location = locationCheck.getLocation();
-                return R.ok(country + location);
-            } else {
-                return R.ok(country);
-            }
-
+            String username = locationCheck.getUsername();
+            String name = locationCheck.getName();
+            String phone = locationCheck.getPhone();
+            String longitude = locationCheck.getLongitude();
+            String latitude = locationCheck.getLatitude();
+            String addr = locationCheck.getAddr();
+            String modUsername = locationCheck.getModUsername();
+            String modName = locationCheck.getModName();
+            String modPhone = locationCheck.getModPhone();
+            String message = locationCheck.getMessage();
+
+            locationMap.put("country", country); // 录入国家
+            locationMap.put("username", username); // 账号用户名
+            locationMap.put("name", name); // 录入人姓名
+            locationMap.put("phone", phone); // 录入人电话
+            locationMap.put("longitude", longitude); // 经度
+            locationMap.put("latitude", latitude); // 纬度
+            locationMap.put("address", addr); // 反编译的地址
+            locationMap.put("modUsername", modUsername); // 修改人账号
+            locationMap.put("modName", modName); // 修改人姓名
+            locationMap.put("modPhone", modPhone); // 修改人电话
+            locationMap.put("message", message); // 修改原因
+
+//            if (country.equals("中国")) {
+//                String location = locationCheck.getLocation();
+//                return R.ok(country + location);
+//            } else {
+//                return R.ok(country);
+//            }
+            return R.ok(locationMap);
         }
         return R.fail("地区信息未录入");
     }
 
-    @ApiOperation(value = "根据ip校验clientId设备位置")
+    @ApiOperation(value = "根据ip校验clientId设备位")
     @PostMapping("/ipCheck")
     public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip) {
         if (StringUtils.isBlank(clientId) || StringUtils.isBlank(ip)) {
@@ -97,7 +112,7 @@ public class TLocationCheckController {
         return R.ok(result);
     }
 
-    @ApiOperation(value = "修改录入的位置信息")
+    @ApiOperation(value = "修改定位信息")
     @PostMapping("/updateLocInfo")
     public ResponseModel<?> updateLocInfo(@RequestBody TLocationCheck locationCheck) {
         if (Objects.isNull(locationCheck)) {
@@ -106,13 +121,17 @@ public class TLocationCheckController {
 
         // 售后部同事修改的信息:姓名,电话,username,clientId,国家
         String modUsername = locationCheck.getModUsername();
-        if (!("shouhoumi".equals(modUsername)) && !("admin".equals(modUsername))) {
+//        if (!("shouhoumi".equals(modUsername)) && !("admin".equals(modUsername)) && !("chenfanghao".equals(modUsername)) && !("ethan".equals(modUsername))) {
+//            return R.fail("该账号无权修改");
+//        }
+        Set<String> allowedUsernames = new HashSet<>(Arrays.asList("shouhoumi", "admin", "jiang123", "ethan"));
+        if (!allowedUsernames.contains(modUsername)) {
             return R.fail("该账号无权修改");
         }
         String modName = locationCheck.getModName();
         String modPhone = locationCheck.getModPhone();
         String clientId = locationCheck.getClientId();
-        String location = locationCheck.getLocation();
+//        String location = locationCheck.getLocation();
         String country = locationCheck.getCountry();
         String message = locationCheck.getMessage();
 
@@ -120,12 +139,6 @@ public class TLocationCheckController {
             return R.fail("设备唯一码不能为空");
         }
 
-//        if (country.equals("中国")) {
-//            if (StringUtils.isEmpty(location)) {
-//                return R.fail("国内省市不能为空");
-//            }
-//        }
-
         LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(TLocationCheck::getClientId, clientId);
         List<TLocationCheck> checks = locationCheckService.list(wrapper);
@@ -137,7 +150,7 @@ public class TLocationCheckController {
 //        tLocationCheck.setModAdminId(modAdminId);
         tLocationCheck.setModPhone(modPhone);
         tLocationCheck.setModUsername(modUsername);
-        tLocationCheck.setLocation(location);
+//        tLocationCheck.setLocation(location);
         tLocationCheck.setClientId(clientId);
         tLocationCheck.setCountry(country);
         tLocationCheck.setMessage(message);
@@ -149,19 +162,19 @@ public class TLocationCheckController {
     }
 
 
-    @ApiOperation(value = "录入位信息")
+    @ApiOperation(value = "录入位信息")
     @PostMapping("/inputLocInfo")
     public ResponseModel<?> inputLocInfo(@RequestBody TLocationCheck locationCheck) {
         if (Objects.isNull(locationCheck)) {
             return R.fail("参数不能为空");
         }
 
+        String name = locationCheck.getName();
         String phone = locationCheck.getPhone();
         String username = locationCheck.getUsername();
         String clientId = locationCheck.getClientId();
-        String name = locationCheck.getName();
-        String location = locationCheck.getLocation();
-        String country = locationCheck.getCountry();
+        String country = locationCheck.getCountry(); // 国家
+//        String location = locationCheck.getLocation(); // 地区
 
         if (Objects.isNull(clientId)) {
             return R.fail("设备唯一码不能为空");
@@ -173,7 +186,7 @@ public class TLocationCheckController {
             return R.fail("此设备信息已录入");
         }
 
-        Set<String> allowedUsers = new HashSet<>(Arrays.asList("admin", "sunchao", "huangkantong", "shouhou121", "shouhou369", "shouhou397", "shouhoumi"));
+        Set<String> allowedUsers = new HashSet<>(Arrays.asList("admin", "jiang123", "shouhou121", "shouhou369", "shouhou397", "shouhoumi", "zhl123", "ethan"));
         if (!allowedUsers.contains(username)) {
             return R.fail("该账号无权操作");
         }
@@ -183,12 +196,12 @@ public class TLocationCheckController {
         String uuid = IdUtil.simpleUUID();
         tLocationCheck.setId(uuid);
         tLocationCheck.setCreateTime(new Date());
+        tLocationCheck.setName(name);
         tLocationCheck.setPhone(phone);
         tLocationCheck.setUsername(username);
         tLocationCheck.setClientId(clientId);
-        tLocationCheck.setName(name);
-        tLocationCheck.setLocation(location);
         tLocationCheck.setCountry(country);
+//        tLocationCheck.setLocation(location);
 
         locationCheckService.save(tLocationCheck);
 

+ 2 - 17
src/main/java/com/szwl/controller/TLogoController.java

@@ -1,18 +1,11 @@
 package com.szwl.controller;
 
-
-import cn.com.sand.third.com.fasterxml.jackson.core.type.TypeReference;
-import cn.com.sand.third.com.fasterxml.jackson.databind.JsonNode;
-import cn.com.sand.third.com.fasterxml.jackson.databind.ObjectMapper;
 import com.gexin.fastjson.JSON;
 import com.gexin.fastjson.JSONObject;
-import com.mysql.cj.util.StringUtils;
 import com.szwl.model.bo.JsonMessage;
 import com.szwl.model.bo.R;
 import com.szwl.model.bo.ResponseModel;
-import com.szwl.model.entity.IDRequest;
 import com.szwl.model.entity.TEquipment;
-import com.szwl.model.entity.TLogo;
 import com.szwl.model.utils.PushUtils;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TEquipmentService;
@@ -21,14 +14,10 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.jws.Oneway;
-import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Optional;
 
-import static com.szwl.constant.ResponseCodesEnum.P0001;
 
 /**
  * <p>
@@ -59,7 +48,7 @@ public class TLogoController {
         if (equipment == null) {
             return R.fail("设备为空");
         }
-        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("customLogo", logoNumber).toString());
+        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateLogo", logoNumber).toString());
         return R.ok();
     }
 
@@ -73,10 +62,6 @@ public class TLogoController {
         map.put("logoNumber", logoNumber);
         String logoNumberJson = JSON.toJSONString(map);
 
-//        ObjectMapper objectMapper = new ObjectMapper();
-//                    JsonNode logoNumberNode = objectMapper.readTree(logoNumberJson);
-//            String logoNumberStr = logoNumberNode.path("logoNumber").path("_value").asText();
-
         JSONObject jsonObject = JSON.parseObject(logoNumberJson);
         String logoNumberStr = jsonObject.getJSONObject("logoNumber").getString("_value");
 
@@ -84,7 +69,7 @@ public class TLogoController {
         if (Objects.isNull(equipment)) {
             return JsonMessage.error("该设备不存在");
         }
-        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("customLogo", logoNumberStr).toString());
+        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateLogo", logoNumberStr).toString());
         return JsonMessage.success("发送成功");
     }
 

+ 5 - 4
src/main/java/com/szwl/controller/TMessageCodeController.java

@@ -56,6 +56,7 @@ public class TMessageCodeController {
         return R.ok(lastSendTime); // 返回时间戳
     }
 
+
     @ApiOperation(value = "发送注册验证码")
     @PostMapping("/sentRegisterCode")
     public ResponseModel<?> sentRegisterCode(String ifForeign, String phoneOrEmail, String hostName) {
@@ -118,8 +119,8 @@ public class TMessageCodeController {
             if (list.size() > 0) {
                 return R.fail(ResponseCodesEnum.A0207, "用户邮箱已存在");
             }
-            //国外发邮件
-            String result = tMessageCodeService.sentEmail("0", phoneOrEmail);
+            //海外发邮件验证码
+            String result = tMessageCodeService.sendEmailAbroad("0", phoneOrEmail);
             return R.ok(result);
         }
     }
@@ -193,8 +194,8 @@ public class TMessageCodeController {
             if (list.size() <= 0) {
                 return R.fail(ResponseCodesEnum.A0001, "登录名或邮箱出错");
             }
-            //海外发邮件
-            String result = tMessageCodeService.sentEmail("1", phoneOrEmail);
+            //海外发邮件验证码
+            String result = tMessageCodeService.sendEmailAbroad("1", phoneOrEmail);
             return R.ok(result);
         }
     }

+ 6 - 0
src/main/java/com/szwl/controller/TNoticeController.java

@@ -49,6 +49,7 @@ public class TNoticeController {
         tNotice.setTitle(notice.getTitle());
         tNotice.setNote(notice.getNote());
         tNotice.setStatus("0");
+        tNotice.setCompanyType(notice.getCompanyType());
         noticeService.save(tNotice);
         return R.ok(tNotice,"添加成功");
     }
@@ -60,8 +61,13 @@ public class TNoticeController {
             return R.fail(ResponseCodesEnum.A0001,"数据有空");
         }
         TAdmin admin = tAdminService.getById(adminId);
+        String companyType = admin.getCompanyType();
+        if(StringUtils.isEmpty(companyType)) {
+            companyType = "0";
+        }
         LambdaQueryWrapper<TNotice> query = Wrappers.lambdaQuery();
         query.eq(TNotice::getStatus,"0");
+        query.eq(TNotice::getCompanyType,companyType);
         query.orderByDesc(TNotice::getCreateDate);
         List<TNotice> notices = noticeService.list(query);
         if(notices.size() > 0){

+ 12 - 15
src/main/java/com/szwl/controller/TOrderController.java

@@ -113,10 +113,10 @@ public class TOrderController {
             return R.fail(ResponseCodesEnum.A0002,"订单非支付状态");
         }
         //判断是不是直连微信退款
-        if(StringUtils.isNotEmpty(order.getPayPlatform())&&order.getPayPlatform().equals("3")){
-            String ifSuccess = R.getDataIfSuccess(payFeign.refund(order.getSn(),refusePrice));
-            return R.ok(ifSuccess);
-        }
+//        if(StringUtils.isNotEmpty(order.getPayPlatform())&&order.getPayPlatform().equals("3")){
+//            String ifSuccess = R.getDataIfSuccess(payFeign.refund(order.getSn(),refusePrice));
+//            return R.ok(ifSuccess);
+//        }
 
         String notifyUrl = JoinpayConstant.Notify_Refund_Url;
 
@@ -152,7 +152,6 @@ public class TOrderController {
                 refInfo.put("altMchNo", altInfoObject.getString("altMchNo"));
                 String altAmount = altInfoObject.getString("altAmount");
                 BigDecimal altAmountPrice = new BigDecimal(altAmount);
-//                altAmountPrice = altAmountPrice.multiply(refusePrice.divide(order.getPrice(),2,BigDecimal.ROUND_HALF_UP)).setScale(2, RoundingMode.HALF_DOWN);
                 p = p.add(altAmountPrice);
                 refInfo.put("altRefAmount", altAmountPrice.toString());
                 if(order.getMarketingAmount()!=null){
@@ -174,9 +173,6 @@ public class TOrderController {
                 String altAmount = altInfoObject.getString("altAmount");
 
                 BigDecimal altAmountPrice = new BigDecimal(altAmount).setScale(2, RoundingMode.HALF_DOWN);
-//                BigDecimal divide = altAmountPrice.divide(order.getPrice(),3,BigDecimal.ROUND_HALF_UP).setScale(3, RoundingMode.HALF_DOWN);
-//                altAmountPrice = refusePrice.multiply(divide).setScale(2, RoundingMode.HALF_DOWN);
-//                refInfo.put("altRefAmount", altAmountPrice.toString());
                 p = p.add(altAmountPrice);
                 refInfo.put("altRefAmount", altAmountPrice.toString());
                 if(order.getMarketingAmount()!=null){
@@ -207,7 +203,6 @@ public class TOrderController {
                 Date date = order.getCreateDate();
                 String payDate = DateTools.formatYYYYMMDD(date);
                 String remark = "";
-//                BigDecimal refundAmount = order.getRefundAmount();
                 // 判断是否退过款
                 if(refundAmount != null && refundAmount.compareTo(BigDecimal.ZERO) > 0) {
                     acctSplitBunch = getAcctSplitBunch(proportion, refusePrice, companyType).toString();
@@ -225,9 +220,10 @@ public class TOrderController {
                     payFeign.updateOrder(order);
                     // 修改订单明细
                     for (TOrderDetails orderDetail : orderDetails) {
-                        String productNo = orderDetail.getProductNo();
-                        Integer productNumber = refundMap.get(productNo);
-                        if(productNumber != null) {
+//                        String productNo = orderDetail.getProductNo();
+                        String orderDetailId = orderDetail.getId();
+                        Integer productNumber = refundMap.get(orderDetailId);
+                        if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
                             // 退款中
                             orderDetail.setRefundStatus("4");
                             // 退款数量
@@ -260,9 +256,10 @@ public class TOrderController {
                     }
                     // 修改订单明细
                     for (TOrderDetails orderDetail : orderDetails) {
-                        String productNo = orderDetail.getProductNo();
-                        Integer productNumber = refundMap.get(productNo);
-                        if(productNumber != null) {
+//                        String productNo = orderDetail.getProductNo();
+                        String orderDetailId = orderDetail.getId();
+                        Integer productNumber = refundMap.get(orderDetailId);
+                        if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
                             // 退款中
                             orderDetail.setRefundStatus("4");
                             // 退款数量

+ 53 - 56
src/main/java/com/szwl/controller/TParametersController.java

@@ -4,7 +4,6 @@ package com.szwl.controller;
 import cn.com.crbank.ommo.bean.ResultMessage;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage;
 import com.szwl.constant.ResponseCodesEnum;
 import com.szwl.model.bean.CommonParamVo;
 import com.szwl.model.bo.R;
@@ -12,14 +11,12 @@ import com.szwl.model.bo.ResponseModel;
 import com.szwl.model.entity.TEquipment;
 import com.szwl.model.entity.TEquipmentDesc;
 import com.szwl.model.entity.TParameters;
-import com.szwl.model.entity.TProduct;
 import com.szwl.model.utils.PushUtils;
 import com.szwl.service.TEquipmentDescService;
 import com.szwl.service.TEquipmentService;
 import com.szwl.service.TParametersService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -40,7 +37,7 @@ import java.util.Objects;
  * </p>
  *
  * @author wuhs
- * @since 2022-04-23
+ * @since 2024-02-23
  */
 @Api(value = "/tParameters", tags = {"参数"})
 @RestController
@@ -57,8 +54,7 @@ public class TParametersController {
 
     /**
      * 获取设备参数
-     *
-     * @param
+     * @param parameters
      * @return
      */
     @PostMapping("/getParameters")
@@ -67,11 +63,11 @@ public class TParametersController {
         String status = parameters.getStatus();
         String clientId = parameters.getClientId();
         LambdaQueryWrapper<TParameters> query = Wrappers.lambdaQuery();
-        query.eq(TParameters::getEquipmentId,equipmentId);
-        query.eq(TParameters::getClientId,clientId);
-        query.eq(TParameters::getStatus,status);
+        query.eq(TParameters::getEquipmentId, equipmentId);
+        query.eq(TParameters::getClientId, clientId);
+        query.eq(TParameters::getStatus, status);
         List<TParameters> parametersList = tParametersService.list(query);
-        if(parametersList.size()==0){
+        if (parametersList.size() == 0) {
             return ResponseEntity
                     .status(HttpStatus.OK)
                     .body(new ResultMessage()
@@ -86,10 +82,10 @@ public class TParametersController {
                         .setData(parametersList)
                         .setMessage("SUCCESS"));
     }
+
     /**
      * 推送设备共同以及/设备参数
-     *
-     * @param
+     * @param commonParamVo
      * @return
      */
     @PostMapping("/updateParameters")
@@ -107,64 +103,65 @@ public class TParametersController {
     }
 
 
-    @ApiOperation(value = "启用物料监控")
+//    @ApiOperation(value = "启用物料监控")
+//    @PostMapping("/enableMaterial")
+//    public ResponseModel<?> enableMaterial(@RequestBody TParameters parameters) {
+//        Long equipmentId = parameters.getEquipmentId();
+//        if (equipmentId == null) {
+//            return R.fail(ResponseCodesEnum.A0001, "设备id不能为空");
+//        }
+////        TParameters tParameters = tParametersService.getById(equipmentId);
+////        if (Objects.isNull(tParameters)) {
+////            TParameters tParameters1 = new TParameters();
+////        }
+//        TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipmentId);
+//        if (Objects.isNull(equipmentDesc)) {
+//            TEquipmentDesc tEquipmentDesc = new TEquipmentDesc();
+//            tEquipmentDesc.setEquipmentId(equipmentId);
+//            tEquipmentDesc.setIsMaterialUse("1");
+//            equipmentDescService.saveOrUpdate(tEquipmentDesc);
+//        } else {
+//            String isMaterialUse = equipmentDesc.getIsMaterialUse();
+//            if (StringUtils.isNotEmpty(isMaterialUse) && "1".equals(isMaterialUse)) {
+//                return R.ok(ResponseCodesEnum.ALL_OK, "已开启ENABLED");
+//            }
+//            equipmentDesc.setIsMaterialUse("1");
+//            equipmentDescService.saveOrUpdate(equipmentDesc);
+//        }
+//
+//        TEquipment equipment = tEquipmentService.getById(equipmentId);
+//        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", "M502" + ":" + "1").toString());
+//
+//        return R.ok(ResponseCodesEnum.ALL_OK, "已发送Send");
+//    }
+
+    @ApiOperation(value = "物料监控")
     @PostMapping("/enableMaterial")
     public ResponseModel<?> enableMaterial(@RequestBody TParameters parameters) {
         Long equipmentId = parameters.getEquipmentId();
         if (equipmentId == null) {
-            return R.fail(ResponseCodesEnum.A0001,"设备id不能为空");
-        }
-//        TParameters tParameters = tParametersService.getById(equipmentId);
-//        if (Objects.isNull(tParameters)) {
-//            TParameters tParameters1 = new TParameters();
-//        }
-        TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipmentId);
-        if (Objects.isNull(equipmentDesc)) {
-            TEquipmentDesc tEquipmentDesc = new TEquipmentDesc();
-            tEquipmentDesc.setEquipmentId(equipmentId);
-            tEquipmentDesc.setIsMaterialUse("1");
-            equipmentDescService.saveOrUpdate(tEquipmentDesc);
-        } else {
-            String isMaterialUse = equipmentDesc.getIsMaterialUse();
-            if (StringUtils.isNotEmpty(isMaterialUse) && "1".equals(isMaterialUse)) {
-                return R.ok(ResponseCodesEnum.ALL_OK,"已开启ENABLED");
-            }
-            equipmentDesc.setIsMaterialUse("1");
-            equipmentDescService.saveOrUpdate(equipmentDesc);
+            return R.fail(ResponseCodesEnum.A0001, "设备id不能为空");
         }
+        String materialMonitorStatus = parameters.getMaterialMonitorStatus();
 
-        TEquipment equipment = tEquipmentService.getById(equipmentId);
-        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", "M502" + ":" + "1").toString());
-
-        return R.ok(ResponseCodesEnum.ALL_OK,"开启物料监控功能成功SUCCESS");
-    }
-
-    @ApiOperation(value = "关闭物料监控")
-    @PostMapping("/disableMaterial")
-    public ResponseModel<?> disableMaterial(@RequestBody TParameters parameters) {
-        Long equipmentId = parameters.getEquipmentId();
-        if (equipmentId == null) {
-            return R.fail(ResponseCodesEnum.A0001,"设备id不能为空");
-        }
         TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipmentId);
         if (Objects.isNull(equipmentDesc)) {
             TEquipmentDesc tEquipmentDesc = new TEquipmentDesc();
             tEquipmentDesc.setEquipmentId(equipmentId);
-            tEquipmentDesc.setIsMaterialUse("0");
+            tEquipmentDesc.setIsMaterialUse("0"); // 默认未启用
             equipmentDescService.saveOrUpdate(tEquipmentDesc);
-        } else {
-            String isMaterialUse = equipmentDesc.getIsMaterialUse();
-            if (StringUtils.isNotEmpty(isMaterialUse) && "0".equals(isMaterialUse)) {
-                return R.ok(ResponseCodesEnum.ALL_OK,"已关闭CLOSED");
-            }
-            equipmentDesc.setIsMaterialUse("0");
-            equipmentDescService.saveOrUpdate(equipmentDesc);
         }
-
         TEquipment equipment = tEquipmentService.getById(equipmentId);
-        tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", "M502" + ":" + "0").toString());
+        if ("1".equals(materialMonitorStatus)) { // 当前是开启状态,用户点击后通知关闭
+//            equipmentDesc.setIsMaterialUse("0");
+            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", "M502" + ":" + "0").toString());
+            return R.ok(ResponseCodesEnum.ALL_OK, "已通知关闭");
+        } else { // 当前是未开启状态,用户点击后通知启用
+//            equipmentDesc.setIsMaterialUse("1");
+            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("Param", "M502" + ":" + "1").toString());
+            return R.ok(ResponseCodesEnum.ALL_OK, "已通知开启");
+        }
 
-        return R.ok(ResponseCodesEnum.ALL_OK,"物料监控已关闭CLOSED");
     }
 
 }

+ 17 - 1
src/main/java/com/szwl/controller/TProductController.java

@@ -15,12 +15,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TNameDictionary;
 import com.szwl.model.entity.TProduct;
 
 import com.szwl.model.query.TEquipmentParam;
 import com.szwl.model.utils.PushUtils;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TEquipmentService;
+import com.szwl.service.TNameDictionaryService;
 import com.szwl.service.TProductService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -47,13 +49,19 @@ import java.util.List;
 @RestController
 @RequestMapping("/tProduct")
 public class TProductController {
+
     @Autowired
     TEquipmentService tEquipmentService;
+
     @Autowired
     TProductService tProductService;
+
     @Autowired
     TAdminService tAdminService;
 
+    @Autowired
+    TNameDictionaryService nameDictionaryService;
+
     @ApiOperation(value = "查询商品列表信息")
     @GetMapping("/selectProducts")
     public ResponseEntity<?> selectProducts(String equipmentId){
@@ -93,7 +101,15 @@ public class TProductController {
                 if(StringUtils.isEmpty(product.getShowType())){
                     productBean.setShowType("0");
                 }
-                productBean.setProductName(product.getProductName());
+                if (StringUtils.isNotEmpty(product.getName())) {
+                    productBean.setProductName(product.getProductName());
+                } else {
+                    LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
+                    wrapper.eq(TNameDictionary::getNo, product.getNo());
+                    wrapper.eq(TNameDictionary::getLanguage, "zh");
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(wrapper);
+                    productBean.setProductName(nameDictionary.getName());
+                }
                 list.add(productBean);
             }
         }

+ 238 - 172
src/main/java/com/szwl/controller/TPromoCodeController.java

@@ -16,6 +16,7 @@ import com.szwl.model.bo.JsonMessage;
 import com.szwl.model.bo.R;
 import com.szwl.model.bo.ResponseModel;
 import com.szwl.model.dto.PromoCodeTarget;
+import com.szwl.model.dto.PromoCodeTargetEn;
 import com.szwl.model.entity.*;
 import com.szwl.model.utils.DateUtils;
 import com.szwl.service.*;
@@ -33,11 +34,12 @@ import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.szwl.constant.ResponseCodesEnum.A0001;
-import static com.szwl.constant.ResponseCodesEnum.A0002;
+import static com.szwl.constant.ResponseCodesEnum.*;
 import static com.szwl.model.utils.DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss;
 
 /**
@@ -66,83 +68,88 @@ public class TPromoCodeController {
     TJoinpayMchService joinpayMchService;
     @Autowired
     PayFeign payFeign;
+
     @ApiOperation(value = "获取优惠码")
     @GetMapping("/getTPromoCode")
-    public ResponseModel<IPage<TPromoCode>> getTPromoCode(@RequestParam String  code) {
+    public ResponseModel<IPage<TPromoCode>> getTPromoCode(@RequestParam String code) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getCode,code);
+        query.eq(TPromoCode::getCode, code);
         Page<TPromoCode> page = new Page<>(1, 10, true);
         IPage<TPromoCode> iPage = promoCodeService.page(page, query);
         return R.ok(iPage);
     }
+
     @ApiOperation(value = "获取优惠码")
     @GetMapping("/getPromoCode")
-    public ResponseModel<TPromoCode> getPromoCode(@RequestParam String  code) {
+    public ResponseModel<TPromoCode> getPromoCode(@RequestParam String code) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
         String[] split = code.split("-");
-        query.eq(TPromoCode::getCode,split[0]);
-        query.eq(TPromoCode::getAdminId,split[1]);
+        query.eq(TPromoCode::getCode, split[0]);
+        query.eq(TPromoCode::getAdminId, split[1]);
         List<TPromoCode> list = promoCodeService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             return R.ok(list.get(0));
         }
         return R.ok();
     }
+
     @ApiOperation(value = "获取优惠码")
     @GetMapping("/selectTPromoCode")
-    public ResponseModel<TPromoCode> selectTPromoCode(@RequestParam String  code,@RequestParam String  adminId) {
+    public ResponseModel<TPromoCode> selectTPromoCode(@RequestParam String code, @RequestParam String adminId) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getCode,code);
-        query.eq(TPromoCode::getAdminId,adminId);
+        query.eq(TPromoCode::getCode, code);
+        query.eq(TPromoCode::getAdminId, adminId);
 //        List<TPromoCode> list = promoCodeService.list(query);
         TPromoCode promoCode = promoCodeService.getOne(query);
         return R.ok(promoCode);
     }
+
     @ApiOperation(value = "小程序获取优惠码")
     @GetMapping("/getCode")
-    public ResponseModel<TPromoCode> getCode(String  clientId, String  code) {
-        if(StringUtils.isEmpty(clientId)){
+    public ResponseModel<TPromoCode> getCode(String clientId, String code) {
+        if (StringUtils.isEmpty(clientId)) {
             return null;
         }
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> list = tEquipmentService.list(query);
         TEquipment equipment = list.get(0);
         LambdaQueryWrapper<TPromoCode> query1 = Wrappers.lambdaQuery();
-        query1.eq(TPromoCode::getCode,code);
-        query1.eq(TPromoCode::getAdminId,equipment.getAdminId());
+        query1.eq(TPromoCode::getCode, code);
+        query1.eq(TPromoCode::getAdminId, equipment.getAdminId());
         List<TPromoCode> list1 = promoCodeService.list(query1);
-        if(list1.size()>0){
+        if (list1.size() > 0) {
             TPromoCode tPromoCode = list1.get(0);
             String isUse = tPromoCode.getIsUse();
-            if(isUse.equals("1")){
-                return R.fail(A0002,"已使用");
+            if (isUse.equals("1")) {
+                return R.fail(A0002, "已使用");
             }
             Date lastUseDate = tPromoCode.getLastUseDate();
             Date date = new Date();
-            if(date.getTime()>lastUseDate.getTime()){
-                return R.fail(A0002,"已过期");
+            if (date.getTime() > lastUseDate.getTime()) {
+                return R.fail(A0002, "已过期");
             }
             return R.ok(tPromoCode);
-        }else {
-            return R.fail(A0002,"没有找到优惠码");
+        } else {
+            return R.fail(A0002, "没有找到优惠码");
         }
     }
+
     @ApiOperation(value = "修改优惠码状态")
     @GetMapping("/updateCode")
-    public ResponseModel<?> updateCode(String  clientId, String  code) {
-        if(StringUtils.isEmpty(clientId)){
+    public ResponseModel<?> updateCode(String clientId, String code) {
+        if (StringUtils.isEmpty(clientId)) {
             return null;
         }
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> list = tEquipmentService.list(query);
         TEquipment equipment = list.get(0);
         LambdaQueryWrapper<TPromoCode> query1 = Wrappers.lambdaQuery();
-        query1.eq(TPromoCode::getCode,code);
-        query1.eq(TPromoCode::getAdminId,equipment.getAdminId());
+        query1.eq(TPromoCode::getCode, code);
+        query1.eq(TPromoCode::getAdminId, equipment.getAdminId());
         List<TPromoCode> list1 = promoCodeService.list(query1);
-        if(list1.size()>0){
+        if (list1.size() > 0) {
             TPromoCode tPromoCode = list1.get(0);
             tPromoCode.setIsUse("1");
             if (StringUtils.isNotEmpty(equipment.getName())) {
@@ -154,56 +161,64 @@ public class TPromoCodeController {
             String time = sdf.format(new Date());
             tPromoCode.setUseDate(time);
             promoCodeService.updateById(tPromoCode);
-            return R.ok(null,"修改成功");
-        }else {
-            return R.fail(A0002,"没有找到优惠码");
+            return R.ok(null, "修改成功");
+        } else {
+            return R.fail(A0002, "没有找到优惠码");
         }
     }
+
     @ApiOperation(value = "修改优惠码")
     @GetMapping("/updatePromoCode")
-    public void updatePromoCode(@RequestParam(value = "id")String id, @RequestParam(value = "type")String type) {
+    public void updatePromoCode(@RequestParam(value = "id") String id, @RequestParam(value = "type") String type) {
         TPromoCode promoCode = promoCodeService.getById(id);
         promoCode.setIsUse(type);
-        if(type.equals("1")){
-            promoCode.setUseDate(DateUtils.formatDate(new Date(),PATTERN_yyyy_MM_dd_HH_mm_ss));
+        if (type.equals("1")) {
+            promoCode.setUseDate(DateUtils.formatDate(new Date(), PATTERN_yyyy_MM_dd_HH_mm_ss));
         }
         promoCodeService.updateById(promoCode);
     }
+
     @ApiOperation(value = "生成0折优惠码")
     @GetMapping("/addPromoCode")
-    public void addPromoCode(@RequestParam(value = "adminId")String adminId,@RequestParam(value = "lastUseDate")Date lastUseDate,@RequestParam(value = "number")String number) {
+    public void addPromoCode(@RequestParam(value = "adminId") String adminId, @RequestParam(value = "lastUseDate") Date lastUseDate,
+                             @RequestParam(value = "number") String number, @RequestParam(value = "codeNum") String codeNum) {
         int num = Integer.parseInt(number);
         List<String> codes = new ArrayList<>();
-        for (int i = 0; i < num; i++) {
-            String code = orderService.initSn(Long.valueOf(adminId));
-            StringBuffer str = new StringBuffer();
-            str.append(code.substring(0, 6));
-            codes.add(str.toString());
+        if (StringUtils.isEmpty(codeNum)) {
+            for (int i = 0; i < num; i++) {
+                String code = orderService.initSn(Long.valueOf(adminId));
+                StringBuffer str = new StringBuffer();
+                str.append(code.substring(0, 6));
+                codes.add(str.toString());
+            }
+        } else {
+            codes.add(codeNum);
         }
         TAdmin admin = adminService.getById(adminId);
         for (String code : codes) {
-                TPromoCode promoCode = new TPromoCode();
-                promoCode.setCreateDate(new Date());
-                promoCode.setModifyDate(new Date());
-                promoCode.setCode(Long.parseLong(code));
-                promoCode.setAdminId(adminId);
-                promoCode.setIsUse("0");
-                promoCode.setDiscount(0f);
-                promoCode.setLastUseDate(lastUseDate);
-                promoCode.setCreateDate(new Date());
-                promoCode.setType("0");
-                promoCode.setUserName(admin.getUsername());
-                promoCodeService.save(promoCode);
+            TPromoCode promoCode = new TPromoCode();
+            promoCode.setCreateDate(new Date());
+            promoCode.setModifyDate(new Date());
+            promoCode.setCode(Long.parseLong(code));
+            promoCode.setAdminId(adminId);
+            promoCode.setIsUse("0");
+            promoCode.setDiscount(0f);
+            promoCode.setLastUseDate(lastUseDate);
+//                promoCode.setCreateDate(new Date());
+            promoCode.setType("0");
+            promoCode.setUserName(admin.getUsername());
+            promoCodeService.save(promoCode);
         }
     }
+
     @ApiOperation(value = "生成n元优惠券")
     @GetMapping("/addYHJ")
-    public ResponseModel<?> addYHJ(Long wxId,String flag) {
-        if(wxId==null||StringUtils.isEmpty(flag)){
+    public ResponseModel<?> addYHJ(Long wxId, String flag) {
+        if (wxId == null || StringUtils.isEmpty(flag)) {
             return R.fail(A0001);
         }
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getWxId,wxId);
+        query.eq(TPromoCode::getWxId, wxId);
 //        if(flag.equals("YHJ5")||flag.equals("YHJ10")){
 //            query.eq(TPromoCode::getType,"2");
 //            List<TPromoCode> list = promoCodeService.list(query);
@@ -211,16 +226,16 @@ public class TPromoCodeController {
 //                return R.ok(1,"此券每人限领一张,您已领取过,不能再领!");
 //            }
 //        }
-        query.eq(TPromoCode::getType,"2");
+        query.eq(TPromoCode::getType, "2");
         List<TPromoCode> list = promoCodeService.list(query);
-        if(list.size()>0){
-            return R.ok(1,"此券每人限领一张,您已领取过,不能再领!");
+        if (list.size() > 0) {
+            return R.ok(1, "此券每人限领一张,您已领取过,不能再领!");
         }
         String code = orderService.initSn(Long.valueOf(wxId));
         TPromoCode promoCode = new TPromoCode();
         promoCode.setCreateDate(new Date());
         promoCode.setModifyDate(new Date());
-        promoCode.setCode(Long.parseLong(code.substring(code.length()-8,code.length())));
+        promoCode.setCode(Long.parseLong(code.substring(code.length() - 8, code.length())));
         promoCode.setAdminId(null);
         promoCode.setIsUse("0");
 //        if(flag.equals("YHJ5")){
@@ -234,31 +249,32 @@ public class TPromoCodeController {
         String[] js = flag.split("J");
         String s = js[1];
         int price = Integer.parseInt(s);
-        if(price>100){
+        if (price > 100) {
             return R.fail(A0001);
         }
         promoCode.setDiscount(Float.valueOf(price));
         promoCode.setType("2");
         Long data = Calendar.getInstance().getTimeInMillis();
         Long t = 3l;
-        Long mon = 30L*24L*60L*60L*1000L;
-        Long d = data + (mon*t);
+        Long mon = 30L * 24L * 60L * 60L * 1000L;
+        Long d = data + (mon * t);
         Date lastUseDate = new Date(Long.parseLong(String.valueOf(d)));
         promoCode.setLastUseDate(lastUseDate);
         promoCode.setCreateDate(new Date());
         promoCode.setUserName(null);
         promoCode.setWxId(wxId);
         promoCodeService.save(promoCode);
-        return R.ok(promoCode,"领取成功");
+        return R.ok(promoCode, "领取成功");
     }
+
     @ApiOperation(value = "核销优惠券")
     @GetMapping("/useYHJ")
-    public void useYHJ(@RequestParam String code,@RequestParam String adminId,@RequestParam String clentId) {
+    public void useYHJ(@RequestParam String code, @RequestParam String adminId, @RequestParam String clentId) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getCode,code);
-        query.eq(TPromoCode::getIsUse,"0");
+        query.eq(TPromoCode::getCode, code);
+        query.eq(TPromoCode::getIsUse, "0");
         List<TPromoCode> list = promoCodeService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             TPromoCode promoCode = list.get(0);
             promoCode.setUseDate(DateUtils.formatDate(new Date(), DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss));
             promoCode.setAdminId(adminId);
@@ -268,44 +284,47 @@ public class TPromoCodeController {
             promoCodeService.updateById(promoCode);
         }
     }
+
     @GetMapping("/getYHJList")
     public ResponseModel<?> getYHJList(Long wxId) {
-        if(wxId==null){
+        if (wxId == null) {
             return R.fail(A0001);
         }
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getWxId,wxId);
-        query.eq(TPromoCode::getIsUse,"0");
-        query.eq(TPromoCode::getType,"2");
+        query.eq(TPromoCode::getWxId, wxId);
+        query.eq(TPromoCode::getIsUse, "0");
+        query.eq(TPromoCode::getType, "2");
         List<TPromoCode> list = promoCodeService.list(query);
-        return R.ok(list,"成功");
+        return R.ok(list, "成功");
     }
+
     @GetMapping("/checkYHJList")
     public ResponseModel<?> checkYHJList(Long wxId) {
-        if(wxId==null){
+        if (wxId == null) {
             return R.fail(A0001);
         }
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getWxId,wxId);
-        query.eq(TPromoCode::getType,"2");
+        query.eq(TPromoCode::getWxId, wxId);
+        query.eq(TPromoCode::getType, "2");
         List<TPromoCode> list = promoCodeService.list(query);
-        if(list.size()>0){
-            return R.ok(true,"已领取");
-        }else {
-            return R.ok(false,"未领取");
+        if (list.size() > 0) {
+            return R.ok(true, "已领取");
+        } else {
+            return R.ok(false, "未领取");
         }
 
     }
+
     @GetMapping("/getYHJ")
     public ResponseModel<TPromoCode> getYHJ(@RequestParam String code) {
-        if(StringUtils.isEmpty(code)){
+        if (StringUtils.isEmpty(code)) {
             return R.fail(A0001);
         }
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        query.eq(TPromoCode::getCode,code);
-        query.eq(TPromoCode::getType,"2");
+        query.eq(TPromoCode::getCode, code);
+        query.eq(TPromoCode::getType, "2");
         List<TPromoCode> list = promoCodeService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             TPromoCode tPromoCode = list.get(0);
 //            String isUse = tPromoCode.getIsUse();
 //            if(isUse.equals("1")){
@@ -320,36 +339,65 @@ public class TPromoCodeController {
         }
         return R.ok();
     }
+
     @ApiOperation(value = "添加优惠码")
     @GetMapping("/add")
-    public ResponseModel<?> add(Long adminId,int number,Float discount,Float month,String type,String frpCode) {
-        if(discount==null||month==null||adminId==null||StringUtils.isEmpty(type)){
+    public ResponseModel<?> add(String addMode, String codeNum,
+                                Long adminId, int number, Float discount,
+                                Float month, String type, String frpCode) {
+        if (discount == null || month == null || adminId == null || StringUtils.isEmpty(type)) {
             return R.fail(A0001);
         }
+        if (addMode.equals("2")) {
+            if (StringUtils.isEmpty(codeNum)) {
+                return R.fail(A0001, "优惠码为空");
+            }
+            LambdaQueryWrapper<TPromoCode> query = new LambdaQueryWrapper<>();
+            query.eq(TPromoCode::getCode, codeNum);
+            query.eq(TPromoCode::getIsUse, 0);
+            query.eq(TPromoCode::getAdminId, adminId);
+            TPromoCode tPromoCode = promoCodeService.getOne(query);
+            if (tPromoCode != null) {
+                // 已存在优惠码
+                return R.fail(A0002, "已存在该优惠码");
+            }
+        }
         TAdmin admin = adminService.getById(adminId);
-        if(String.valueOf(admin.getId()).equals("1")){
-            List<String> codes =new ArrayList<>();
-            for(int i=0;i<number;i++){
-                StringBuilder num = new StringBuilder();
-                Random random = new Random();
-                for (int j = 0; j < 8; j++) {
-                    num.append(String.valueOf(random.nextInt(10)));
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime startOfToday = now.with(LocalTime.MIN);
+        LocalDateTime endOfToday = now.with(LocalTime.MAX);
+        LambdaQueryWrapper<TPromoCode> promoCodeWrapper = new LambdaQueryWrapper<>();
+        promoCodeWrapper.between(TPromoCode::getCreateDate, startOfToday, endOfToday);
+        promoCodeWrapper.eq(TPromoCode::getAdminId, adminId);
+        int countCode = promoCodeService.count(promoCodeWrapper);
+        if (countCode >= 5000) {
+            return R.fail(B0002, "今日优惠码申请已达到上限");
+        }
+        if (String.valueOf(admin.getId()).equals("1")) {
+            List<String> codes = new ArrayList<>();
+            if (addMode.equals("1")) {
+                for (int i = 0; i < number; i++) {
+                    StringBuilder num = new StringBuilder();
+                    Random random = new Random();
+                    for (int j = 0; j < 8; j++) {
+                        num.append(random.nextInt(10));
+                    }
+                    String code = num.toString();
+                    codes.add(code);
                 }
-                String code = num.toString();
-                codes.add(code);
+            } else {
+                codes.add(codeNum);
             }
             Long data = Calendar.getInstance().getTimeInMillis();
-            Float mm = month*10;
+            Float mm = month * 10;
             String m = String.valueOf(mm);
             String[] split = m.split("\\.");
             String th = split[0];
             Long t = Long.valueOf(th);
-            Long mon = 30L*24L*60L*60L*1000L;
-            Long d = data + ((mon*t)/10);
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String sd = sdf.format(new Date(Long.parseLong(String.valueOf(d))));
+            Long mon = 30L * 24L * 60L * 60L * 1000L;
+            Long d = data + ((mon * t) / 10);
             Date lastUseDate = new Date(Long.parseLong(String.valueOf(d)));
-            for(String code : codes){
+            for (String code : codes) {
                 TPromoCode promoCode = new TPromoCode();
                 promoCode.setCode(Long.parseLong(code));
                 promoCode.setAdminId(String.valueOf(admin.getId()));
@@ -361,26 +409,26 @@ public class TPromoCodeController {
                 promoCode.setType(type);
                 promoCodeService.save(promoCode);
             }
-            return R.ok(null,"生成成功");
+            return R.ok(null, "生成成功");
         }
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getAdminId,admin.getId());
+        query.eq(TEquipment::getAdminId, admin.getId());
         List<TEquipment> list = tEquipmentService.list(query);
         TEquipment equipment = list.get(0);
-        if(list.size()==0){
+        if (list.size() == 0) {
             // "要有机器才能购买优惠码";
             return R.fail("没有机器");
         }
         //0折优惠码需要支付
-        if(type.equals("0")&&discount==0){
-            if(admin.getPromoCodeOpen()==null||admin.getPromoCodeOpen().equals("1")){
+        if (type.equals("0") && discount == 0) {
+            if (admin.getPromoCodeOpen() == null || admin.getPromoCodeOpen().equals("1")) {
                 Long equipmentId = equipment.getId();
                 Double money = null;
                 LambdaQueryWrapper<TPrice> query1 = Wrappers.lambdaQuery();
-                query1.eq(TPrice::getName,"优惠码");
+                query1.eq(TPrice::getName, "优惠码");
                 List<TPrice> prices = priceService.list(query1);
-                for(TPrice price:prices){
-                    if(price.getName().equals("优惠码")){
+                for (TPrice price : prices) {
+                    if (price.getName().equals("优惠码")) {
                         money = price.getPrice();
                     }
                 }
@@ -388,11 +436,14 @@ public class TPromoCodeController {
                 String sn = orderService.initSn(client6);
                 String orderNo = sn;
                 String productName = "优惠码";
-                BigDecimal price = BigDecimal.valueOf(money*number);
+                BigDecimal price = BigDecimal.valueOf(money * number);
                 BigDecimal cutPrice = price.multiply(new BigDecimal(100)).divide(new BigDecimal(100));
                 BigDecimal amount = cutPrice;
                 String productDesc = "";
                 String commonParameter = "";
+                if (addMode.equals("2") && StringUtils.isNotEmpty(codeNum)) {
+                    commonParameter = codeNum;
+                }
                 String returnUrl = null;
                 String notifyUrl = JoinpayConstant.Notify_Url_PromoCode;
                 String isShowPic = "1";
@@ -449,27 +500,28 @@ public class TPromoCodeController {
             }
 
         }
-//        Long equipmentId = equipment.getId();
         Long client6 = Long.parseLong(equipment.getClientId().substring(equipment.getClientId().length() - 6));
-        List<String> codes =new ArrayList<>();
-        for(int i=0;i<number;i++){
-            String code = orderService.initSn(client6);
-            StringBuffer str = new StringBuffer();
-            str.append(code.substring(0,6));
-            codes.add(str.toString());
+        List<String> codes = new ArrayList<>();
+        if (addMode.equals("1")) {
+            for (int i = 0; i < number; i++) {
+                String code = orderService.initSn(client6);
+                StringBuffer str = new StringBuffer();
+                str.append(code.substring(0, 6));
+                codes.add(str.toString());
+            }
+        } else {
+            codes.add(codeNum);
         }
         Long data = Calendar.getInstance().getTimeInMillis();
-        Float mm = month*10;
+        Float mm = month * 10;
         String m = String.valueOf(mm);
         String[] split = m.split("\\.");
         String th = split[0];
         Long t = Long.valueOf(th);
-        Long mon = 30L*24L*60L*60L*1000L;
-        Long d = data + ((mon*t)/10);
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String sd = sdf.format(new Date(Long.parseLong(String.valueOf(d))));
+        Long mon = 30L * 24L * 60L * 60L * 1000L;
+        Long d = data + ((mon * t) / 10);
         Date lastUseDate = new Date(Long.parseLong(String.valueOf(d)));
-        for(String code : codes){
+        for (String code : codes) {
             TPromoCode promoCode = new TPromoCode();
             promoCode.setCode(Long.parseLong(code));
             promoCode.setAdminId(String.valueOf(admin.getId()));
@@ -481,16 +533,17 @@ public class TPromoCodeController {
             promoCode.setType(type);
             promoCodeService.save(promoCode);
         }
-        return R.ok(null,"生成成功");
+        return R.ok("生成成功");
     }
+
     @ApiOperation(value = "获取优惠码列表")
     @GetMapping("/pagePromoCode")
-    public ResponseModel<IPage<?>> pagePromoCode(String adminId , String code, String isUse, Date useStratDate,Date useEndDate,Date createStratDate,Date createEndDate,  long current, long size ) {
+    public ResponseModel<IPage<?>> pagePromoCode(String adminId, String code, String isUse, Date useStratDate, Date useEndDate, Date createStratDate, Date createEndDate, long current, long size) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        if(StringUtils.isNotEmpty(adminId)){
+        if (StringUtils.isNotEmpty(adminId)) {
             TAdmin admin = adminService.getById(adminId);
-            if(admin.getType()!=0 && admin.getType()!=1){
-                query.eq(TPromoCode::getAdminId,adminId);
+            if (admin.getType() != 0 && admin.getType() != 1) {
+                query.eq(TPromoCode::getAdminId, adminId);
             }
             if (admin.getId() == 2738) {
                 LambdaQueryWrapper<TAdmin> adminQuery = Wrappers.lambdaQuery();
@@ -498,7 +551,7 @@ public class TPromoCodeController {
                         .eq(TAdmin::getCompanyType, "0");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TPromoCode::getAdminId,adminIds);
+                query.in(TPromoCode::getAdminId, adminIds);
             }
             // 七云平台管理员
             if (admin.getId() == 2739) {
@@ -506,38 +559,45 @@ public class TPromoCodeController {
                 adminQuery.eq(TAdmin::getCompanyType, "1");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TPromoCode::getAdminId,adminIds);
+                query.in(TPromoCode::getAdminId, adminIds);
             }
-        }else {
+        } else {
             return R.fail(A0001);
         }
-        if(StringUtils.isNotEmpty(code)){
-            query.eq(TPromoCode::getCode,code);
+        if (StringUtils.isNotEmpty(code)) {
+            query.eq(TPromoCode::getCode, code);
         }
-        if(StringUtils.isNotEmpty(isUse)){
-            query.like(TPromoCode::getIsUse,isUse);
+        if (StringUtils.isNotEmpty(isUse)) {
+            query.like(TPromoCode::getIsUse, isUse);
         }
-        if(useStratDate!=null&&useEndDate!=null){
-            query.gt(TPromoCode::getUseDate,useStratDate);
-            query.lt(TPromoCode::getUseDate,useEndDate);
+        if (useStratDate != null && useEndDate != null) {
+            query.gt(TPromoCode::getUseDate, useStratDate);
+            query.lt(TPromoCode::getUseDate, useEndDate);
         }
-        if(createStratDate!=null&&createEndDate!=null){
-            query.gt(TPromoCode::getCreateDate,createStratDate);
-            query.lt(TPromoCode::getCreateDate,createEndDate);
+        if (createStratDate != null && createEndDate != null) {
+            query.gt(TPromoCode::getCreateDate, createStratDate);
+            query.lt(TPromoCode::getCreateDate, createEndDate);
         }
         query.orderByDesc(TPromoCode::getCreateDate);
         Page<TPromoCode> page = new Page<>(current, size, true);
         IPage<TPromoCode> iPage = promoCodeService.page(page, query);
         return R.ok(iPage);
     }
+
     @ApiOperation(value = "导出优惠码列表")
     @GetMapping("/export")
-    public Object export(HttpServletResponse response, String adminId , String code, String isUse, Date useStratDate, Date useEndDate, Date createStratDate, Date createEndDate, long current, long size ) {
+    public Object export(HttpServletResponse response, String adminId, String code, String isUse, Date useStratDate, Date useEndDate, Date createStratDate, Date createEndDate, long current, long size) {
         LambdaQueryWrapper<TPromoCode> query = Wrappers.lambdaQuery();
-        if(StringUtils.isNotEmpty(adminId)){
+        String ifForeign = "0";
+        String head = "优惠码数据-";
+        if (StringUtils.isNotEmpty(adminId)) {
             TAdmin admin = adminService.getById(adminId);
-            if(admin.getType()!=0 && admin.getType()!=1){
-                query.eq(TPromoCode::getAdminId,adminId);
+            if (StringUtils.isNotEmpty(admin.getIfForeign()) && admin.getIfForeign().equals("1")) {
+                ifForeign = admin.getIfForeign();
+                head = "PromoCode-";
+            }
+            if (admin.getType() != 0 && admin.getType() != 1) {
+                query.eq(TPromoCode::getAdminId, adminId);
             }
             // 申泽平台管理员
             if (admin.getId() == 2738) {
@@ -546,7 +606,7 @@ public class TPromoCodeController {
                         .eq(TAdmin::getCompanyType, "0");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TPromoCode::getAdminId,adminIds);
+                query.in(TPromoCode::getAdminId, adminIds);
             }
             // 七云平台管理员
             if (admin.getId() == 2739) {
@@ -554,33 +614,39 @@ public class TPromoCodeController {
                 adminQuery.eq(TAdmin::getCompanyType, "1");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TPromoCode::getAdminId,adminIds);
+                query.in(TPromoCode::getAdminId, adminIds);
             }
-        }else {
+        } else {
             return R.fail(A0001);
         }
-        if(StringUtils.isNotEmpty(code)){
-            query.eq(TPromoCode::getCode,code);
+        if (StringUtils.isNotEmpty(code)) {
+            query.eq(TPromoCode::getCode, code);
         }
-        if(StringUtils.isNotEmpty(isUse)){
-            query.like(TPromoCode::getIsUse,isUse);
+        if (StringUtils.isNotEmpty(isUse)) {
+            query.like(TPromoCode::getIsUse, isUse);
         }
-        if(useStratDate!=null&&useEndDate!=null){
-            query.gt(TPromoCode::getUseDate,useStratDate);
-            query.lt(TPromoCode::getUseDate,useEndDate);
+        if (useStratDate != null && useEndDate != null) {
+            query.gt(TPromoCode::getUseDate, useStratDate);
+            query.lt(TPromoCode::getUseDate, useEndDate);
         }
-        if(createStratDate!=null&&createEndDate!=null){
-            query.gt(TPromoCode::getCreateDate,createStratDate);
-            query.lt(TPromoCode::getCreateDate,createEndDate);
+        if (createStratDate != null && createEndDate != null) {
+            query.gt(TPromoCode::getCreateDate, createStratDate);
+            query.lt(TPromoCode::getCreateDate, createEndDate);
         }
 
         Page<TPromoCode> page = new Page<>(current, size, true);
         IPage<TPromoCode> iPage = promoCodeService.page(page, query);
         List<TPromoCode> list = iPage.getRecords();
-        List<PromoCodeTarget> promoCodeTargets = promoCodeService.findById(list);
-
-        ExportParams exportParams = new ExportParams("优惠码记录", "sheet1");
-        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PromoCodeTarget.class, promoCodeTargets);
+        Workbook workbook = null;
+        if (ifForeign.equals("0")) {
+            List<PromoCodeTarget> promoCodeTargets = promoCodeService.findById(list);
+            ExportParams exportParams = new ExportParams("优惠码记录", "sheet1");
+            workbook = ExcelExportUtil.exportExcel(exportParams, PromoCodeTarget.class, promoCodeTargets);
+        } else {
+            List<PromoCodeTargetEn> promoCodeTargetEns = promoCodeService.exportPromoCode(list);
+            ExportParams exportParams = new ExportParams("Promo code record", "sheet1");
+            workbook = ExcelExportUtil.exportExcel(exportParams, PromoCodeTargetEn.class, promoCodeTargetEns);
+        }
 
         if (workbook != null) {
             OutputStream os = null;
@@ -588,7 +654,7 @@ public class TPromoCodeController {
                 os = response.getOutputStream();
                 SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
                 response.setContentType("application/vnd.ms-excel;charset=utf-8");
-                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("优惠码数据" + format.format(new Date()) + ".xls", "UTF-8"));
+                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(head + format.format(new Date()) + ".xls", "UTF-8"));
                 workbook.write(os);
                 return JsonMessage.success("导出成功");
             } catch (Exception e) {
@@ -610,12 +676,12 @@ public class TPromoCodeController {
     @RequestMapping(value = "/getCodeDiscount", method = RequestMethod.GET)
     @ResponseBody
     public Object getCodeDiscount(String code) {
-        if(!StringUtils.isEmpty(code)){
+        if (!StringUtils.isEmpty(code)) {
             LambdaQueryWrapper<TPromoCode> wrapper = new LambdaQueryWrapper<>();
-            wrapper.in(TPromoCode::getCode,code);
-            wrapper.in(TPromoCode::getIsUse,"0");
+            wrapper.in(TPromoCode::getCode, code);
+            wrapper.in(TPromoCode::getIsUse, "0");
             TPromoCode promoCode = promoCodeService.getOne(wrapper);
-            if(promoCode == null) {
+            if (promoCode == null) {
                 return null;
             }
             Float discount = promoCode.getDiscount();
@@ -624,21 +690,21 @@ public class TPromoCodeController {
             kindData.put("type", type.equals("1") ? type : "0");
             kindData.put("discount", discount);
             return JsonMessage.success(kindData.toString());
-        }else{
+        } else {
             return null;
         }
     }
 
     @ApiOperation(value = "批量删除优惠码")
-    @PostMapping (value = "/deletes")
+    @PostMapping(value = "/deletes")
     @ResponseBody
     public ResponseModel<?> deletes(@RequestBody Long[] ids) {
-        if(ids==null){
+        if (ids == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
-        if(ids.length > 0){
+        if (ids.length > 0) {
             ArrayList<Long> idList = new ArrayList<>();
-            for(int i = 0;i < ids.length; i++){
+            for (int i = 0; i < ids.length; i++) {
                 idList.add(ids[i]);
             }
             promoCodeService.removeByIds(idList);

+ 2 - 2
src/main/java/com/szwl/controller/TProportionController.java

@@ -278,12 +278,12 @@ public class TProportionController {
         if(tProportion.getAdminId()==null||StringUtils.isEmpty(tProportion.getClientId())){
             R.fail("信息有空!");
         }
-        TAdmin admin = adminService.getById(tProportion.getAdminId());
+//        TAdmin admin = adminService.getById(tProportion.getAdminId());
         //查找机器,看改商家是否有该机器
         LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
         query1.eq(TEquipment::getAdminId,tProportion.getAdminId());
         query1.eq(TEquipment::getClientId,tProportion.getClientId());
-        List<TEquipment> equipmentList = tEquipmentService.list(query1);
+//        List<TEquipment> equipmentList = tEquipmentService.list(query1);
         TEquipment equipment = tEquipmentService.getOne(query1);
         if(equipment == null){
             return R.fail("找不到该机器!");

+ 1 - 1
src/main/java/com/szwl/controller/TTimeRuleController.java

@@ -92,7 +92,7 @@ public class TTimeRuleController {
     public ResponseModel<?> getList(String name) {
         LambdaQueryWrapper<TTimeRule> query = Wrappers.lambdaQuery();
         if(StringUtils.isNotEmpty(name)){
-            query.eq(TTimeRule::getName,name);
+            query.like(TTimeRule::getName,name);
         }
         query.orderByDesc(TTimeRule::getCreateDate);
         List<TTimeRule> list = timeRuleService.list(query);

+ 73 - 12
src/main/java/com/szwl/controller/TWechatController.java

@@ -2,7 +2,13 @@ package com.szwl.controller;
 
 
 import cn.com.crbank.ommo.exception.MyException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.szwl.constant.ConfigConsts;
+import com.szwl.constant.ResponseCodesEnum;
 import com.szwl.model.bo.R;
+import com.szwl.model.bo.ResponseModel;
+import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TWechat;
 import com.szwl.model.param.WxBindParam;
 import com.szwl.model.utils.HttpClientUtils;
@@ -41,19 +47,19 @@ import java.util.*;
 public class TWechatController {
 
     @Autowired
-    private TAdminService tAdminService;
+    private TAdminService adminService;
 
     @Autowired
     private TWechatService tWechatService;
 
     // 从 yml 文件中获取
-    @Value("${oauth.wx.appid}")
+//    @Value("${oauth.wx.appid}")
     private String appid;
 
-    @Value("${oauth.wx.appsecret}")
+//    @Value("${oauth.wx.appsecret}")
     private String appsecret;
 
-    @Value("${oauth.callback.http}")
+//    @Value("${oauth.callback.http}")
     private String http;
 
     @ApiOperation(value = "绑定微信")
@@ -63,16 +69,30 @@ public class TWechatController {
         if (adminId == null) {
             throw new MyException("参数为空");
         }
-        String path = http + "/SZWL-SERVER/tWechat/callback";
+        TAdmin admin = adminService.getById(adminId);
+        String companyType = admin.getCompanyType();
+        String path = "";
+        String appId = "";
+        String head = "";
+
+        if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
+            path = ConfigConsts.SC_RETURN_URL + "/SZWL-SERVER/tWechat/callback";
+            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            head = ConfigConsts.SC_RETURN_URL;
+        } else {
+            path = ConfigConsts.SZ_RETURN_URL + "/SZWL-SERVER/tWechat/callback";
+            appId = ConfigConsts.SZ_WX_SUB_APP_ID;
+            head = ConfigConsts.SZ_RETURN_URL;
+        }
 //        String path = http + "/tWechat/callback";
         try {
             // redirectUrl 用于处理微信授权回调请求的页面
             String redirectUrl = URLEncoder.encode(path, "UTF-8");
             // 第一步:用户同意授权,获取code
-            String url = "http://szwlh.sunzee.com.cn/openWeixin/connect/oauth2/authorize?"
+            String url = head + "/openWeixin/connect/oauth2/authorize?"
 //            String url = "http://szwltest.sunzee.com.cn/openWeixin/connect/oauth2/authorize?"
 //            String url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
-                    + "appid=" + appid
+                    + "appid=" + appId
                     + "&redirect_uri=" + redirectUrl
                     + "&response_type=code"
                     + "&scope=snsapi_userinfo"
@@ -91,11 +111,25 @@ public class TWechatController {
         // 获取code
         String code = request.getParameter("code");
         String adminId = request.getParameter("state");
+        TAdmin admin = adminService.getById(adminId);
+        String companyType = admin.getCompanyType();
+        String appId = "";
+        String appSecret = "";
+        String redirectUrl = "";
+        if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
+            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SC_WX_APP_SECRET;
+            redirectUrl = ConfigConsts.SC_RETURN_URL + "/sc/#/user";
+        } else {
+            appId = ConfigConsts.SZ_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SZ_WX_APP_SECRET;
+            redirectUrl = ConfigConsts.SZ_RETURN_URL + "/shenze/#/user";
+        }
 
         // 第二步:通过 code 换取网页授权 access_token 和 openid
         String openUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
-                "appid=" + appid +
-                "&secret=" + appsecret +
+                "appid=" + appId +
+                "&secret=" + appSecret +
                 "&code=" + code +
                 "&grant_type=authorization_code";
 
@@ -110,6 +144,7 @@ public class TWechatController {
                 "&lang=zh_CN";
         JSONObject userInfo = HttpClientUtils.get(userUrl);
         String nickname = userInfo.getString("nickname");
+        nickname = Base64.getEncoder().encodeToString(nickname.getBytes());
         String headimgurl = userInfo.getString("headimgurl");
 
         if (StringUtils.isNotEmpty(openid)) {
@@ -165,7 +200,7 @@ public class TWechatController {
             // 获取微信授权失败
             return R.fail("微信授权失败,没有openid");
         }
-        String redirectUrl = http + "/shenze/#/user";
+//        String redirectUrl = http + "/shenze/#/user";
         response.sendRedirect(redirectUrl);
         return R.ok(userInfo);
     }
@@ -190,12 +225,23 @@ public class TWechatController {
     public Map<String, Object> auth(@RequestBody WxBindParam wxBindParam) {
         String adminId = wxBindParam.getState();
         String code = wxBindParam.getCode();
+        TAdmin admin = adminService.getById(adminId);
+        String companyType = admin.getCompanyType();
+        String appId = "";
+        String appSecret = "";
+        if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
+            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SC_WX_APP_SECRET;
+        } else {
+            appId = ConfigConsts.SZ_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SZ_WX_APP_SECRET;
+        }
         Map<String, Object> result = new HashMap<>();
         try {
             // 第二步:通过 code 换取网页授权 access_token 和 openid
             String openUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
-                    "appid=" + appid +
-                    "&secret=" + appsecret +
+                    "appid=" + appId +
+                    "&secret=" + appSecret +
                     "&code=" + code +
                     "&grant_type=authorization_code";
             System.out.println(openUrl);
@@ -253,5 +299,20 @@ public class TWechatController {
         return result;
     }
 
+    @ApiOperation(value = "获取微信授权openId")
+    @GetMapping("/getOpenId")
+    public ResponseModel<?> getOpenId(@RequestParam("adminId") Long adminId) {
+        if(adminId == null) {
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        LambdaQueryWrapper<TWechat> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(TWechat::getAdminId, adminId);
+        TWechat wechat = tWechatService.getOne(queryWrapper);
+        if(wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
+            return R.ok(wechat.getOpenId());
+        }
+        return R.ok();
+    }
+
 }
 

+ 0 - 46
src/main/java/com/szwl/controller/TestController.java

@@ -1,46 +0,0 @@
-package com.szwl.controller;
-
-import com.szwl.mapper.TLocationCheckMapper;
-import com.szwl.model.entity.TLocationCheck;
-import com.szwl.service.TLocationCheckService;
-import com.szwl.util.WhoIsUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.List;
-
-@Slf4j
-@Api(value = "/tTest", tags = {"测试"})
-@RestController
-@RequestMapping("/tTest")
-public class TestController {
-
-    @Resource
-    TLocationCheckMapper locationCheckMapper;
-    @Resource
-    TLocationCheckService locationCheckService;
-    @ApiOperation(value = "测试定时任务")
-    @PostMapping("/testSch")
-    public void test() throws IOException {
-        List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullIp();
-//            String locErrorEq = null;
-        StringBuilder locErrorEq = new StringBuilder();
-        for (TLocationCheck locationChc : locationChecks) {
-            String clientId = locationChc.getClientId();
-            String ip = locationChc.getIp();
-            String addr = WhoIsUtil.getLocByIp(ip);
-            // 这里不需要更新ip,只需要校验有ip的设备位置对不对
-//                locationCheckService.locCheckMsg(locationChc, clientId, addr);
-            String check = locationCheckService.schLocCheck(locationChc, clientId, addr);
-            locErrorEq.append(check);
-        }
-        locationCheckService.schSendMsg(locErrorEq.toString());
-    }
-
-}

+ 67 - 3
src/main/java/com/szwl/controller/WxLoginController.java

@@ -3,6 +3,7 @@ package com.szwl.controller;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import com.alibaba.fastjson.JSON;
+import com.szwl.constant.ConfigConsts;
 import com.szwl.exception.MyException;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -99,9 +100,6 @@ public class WxLoginController {
         }
     }
 
-    public static void main(String[] args) {
-
-    }
     @ApiOperation(value = "用微信code 获取openid,再获取用户信息")
     @GetMapping("/getUserDetailByWxCode")
     public R getUserDetailByWxCode(String code) {
@@ -126,6 +124,72 @@ public class WxLoginController {
         return R.ok(userDetailBO);
     }
 
+    @ApiOperation(value = "用户默认授权,获取code")
+    @GetMapping("/newMenuOauth")
+    public ResponseModel<?> newMenuOauth(String hostName) {
+        String path = "";
+        String appId = "";
+        String head = "";
+        if(hostName.equals("Sevencloud")) {
+            path = ConfigConsts.SC_RETURN_URL + "/shenzeVue/wxLogin";
+            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            head = ConfigConsts.SC_RETURN_URL;
+        } else {
+            path = ConfigConsts.SZ_RETURN_URL + "/shenzeVue/wxLogin";
+            appId = ConfigConsts.SZ_WX_SUB_APP_ID;
+            head = ConfigConsts.SZ_RETURN_URL;
+        }
+        try {
+            String redirectUrl = URLEncoder.encode(path, "UTF-8");
+            // 第一步:用户静默授权,获取code
+            String authUrl = head + "/openWeixin/connect/oauth2/authorize?"
+//            String authUrl = "http://szwltest.sunzee.com.cn/openWeixin/connect/oauth2/authorize?"
+//            String authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?"
+                    + "appid=" + appId
+                    + "&redirect_uri=" + redirectUrl
+                    + "&response_type=code"
+                    + "&scope=snsapi_base"
+                    + "&state=STATE"
+                    + "#wechat_redirect";
+            return R.ok(authUrl);
+        } catch (UnsupportedEncodingException e) {
+            return R.fail("微信授权失败");
+        }
+    }
+
+    @ApiOperation(value = "用微信code 获取openid,再获取用户信息")
+    @GetMapping("/newGetUserDetailByWxCode")
+    public ResponseModel<?> newGetUserDetailByWxCode(String code, String hostName) {
+        String appId = "";
+        String appSecret = "";
+        if(hostName.equals("Sevencloud")) {
+            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SC_WX_APP_SECRET;
+        } else {
+            appId = ConfigConsts.SZ_WX_SUB_APP_ID;
+            appSecret = ConfigConsts.SZ_WX_APP_SECRET;
+        }
+        // 第二步:使用code换取access_token和openid
+        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?"
+                + "appid=" + appId
+                + "&secret=" + appSecret
+                + "&code=" + code
+                + "&grant_type=authorization_code";
+        HttpResponse httpResponse = HttpRequest.get(url).execute();
+        JSONObject jsonObject = JSON.parseObject(httpResponse.body());
+        log.info("getUserDetailByWxCode:{}",jsonObject);
+        String openid = jsonObject.getString("openid");
+        // 根据openid 获取绑定的用户信息
+        TWechat tWechat = tWechatService.lambdaQuery().eq(TWechat::getOpenId, openid).one();
+        if(null == tWechat){
+            log.info("没有找到绑定的用户信息,请绑定后再登录,openid:",openid);
+            throw new MyException("没有找到绑定的用户信息,请绑定后再登录");
+        }
+        TAdmin tAdmin = tAdminService.getById(tWechat.getAdminId());
+        UserDetailBO userDetailBO = tAdminService.getUserDetailBO(tAdmin);
+        return R.ok(userDetailBO);
+    }
+
     @ApiOperation(value = "使用 Openid 登录")
     @PostMapping("/loginWithOpenid")
     @Audit(type = AuditEnum.LOGIN,content = "#username + '请求登录'")

+ 16 - 0
src/main/java/com/szwl/mapper/TAlarmCleanMapper.java

@@ -0,0 +1,16 @@
+package com.szwl.mapper;
+
+import com.szwl.model.entity.TAlarmClean;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wuhs
+ * @since 2024-04-26
+ */
+public interface TAlarmCleanMapper extends BaseMapper<TAlarmClean> {
+
+}

+ 2 - 0
src/main/java/com/szwl/mapper/TEquipmentMapper.java

@@ -20,6 +20,8 @@ public interface TEquipmentMapper extends BaseMapper<TEquipment> {
 
     String findMachineUseNum(StatisticsParam param);
 
+    String findMachineUseNumAdmin(StatisticsParam param);
+
     int insertBatchSomeColumn(List<TEquipment> entityList);
 
     List<TEquipment> getEquipmentByLatLon(String lat1, String lat2, String lon1, String lon2);

+ 2 - 1
src/main/java/com/szwl/mapper/TLocationCheckMapper.java

@@ -15,5 +15,6 @@ import java.util.List;
  */
 public interface TLocationCheckMapper extends BaseMapper<TLocationCheck> {
 
-    List<TLocationCheck> selectNotNullIp();
+//    List<TLocationCheck> selectNotNullIp();
+    List<TLocationCheck> selectNotNullAddr();
 }

+ 1 - 1
src/main/java/com/szwl/mapper/TParametersMapper.java

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * </p>
  *
  * @author wuhs
- * @since 2022-04-23
+ * @since 2024-02-23
  */
 public interface TParametersMapper extends BaseMapper<TParameters> {
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 7 - 1
src/main/java/com/szwl/mapper/xml/TAdminMapper.xml


+ 23 - 0
src/main/java/com/szwl/mapper/xml/TAlarmCleanMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.szwl.mapper.TAlarmCleanMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.szwl.model.entity.TAlarmClean">
+        <id column="id" property="id" />
+        <result column="admin_id" property="adminId" />
+        <result column="equipment_id" property="equipmentId" />
+        <result column="client_id" property="clientId" />
+        <result column="is_oversea" property="isOversea" />
+        <result column="phone" property="phone" />
+        <result column="email" property="email" />
+        <result column="last_send_time" property="lastSendTime" />
+        <result column="candy_num" property="candyNum" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, admin_id, equipment_id, client_id, is_oversea, phone, email, last_send_time, candy_num
+    </sql>
+
+</mapper>

+ 27 - 2
src/main/java/com/szwl/mapper/xml/TEquipmentMapper.xml

@@ -95,7 +95,32 @@
         </if>
     </select>
 
-    <!-- 获取所有正在运营的机器数量-->
+    <!-- 获取所有正在运营的机器数量admin -->
+    <select id="findMachineUseNumAdmin" parameterType="java.lang.Long" resultType="java.lang.String">
+        SELECT COUNT(id) FROM
+        t_equipment a
+        where 1=1
+        <if test="adminId != null and adminId !=''">
+            and a.admin_id = #{adminId}
+        </if>
+        <choose>
+            <when test="companyType != null and companyType !='' and companyType.equals(&quot;0&quot;)">
+                AND (a.company_type IS NULL OR a.company_type = '0')
+            </when>
+            <when test="companyType != null and companyType !='' and companyType.equals(&quot;1&quot;)">
+                AND a.company_type = '1'
+            </when>
+        </choose>
+        <if test="equipmentIds != null and equipmentIds!=''">
+            AND a.id IN
+            <foreach item="item" index="index" collection="equipmentIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        AND a.last_update_time BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW()
+    </select>
+
+    <!-- 获取所有正在运营的机器数量 -->
     <select id="findMachineUseNum" parameterType="java.lang.Long" resultType="java.lang.String">
         SELECT COUNT(id) FROM
         t_equipment a
@@ -117,7 +142,7 @@
                 #{item}
             </foreach>
         </if>
-        and a.eqe_status='1'
+        AND a.eqe_status = '1'
     </select>
 
     <select id="getEquipmentByLatLon" parameterType="java.lang.String" resultMap="BaseResultMap">

+ 2 - 2
src/main/java/com/szwl/mapper/xml/TLocationCheckMapper.xml

@@ -39,9 +39,9 @@
         id, create_time, modify_time, admin_id, phone, client_id, location, longitude, latitude, country, country_code, username, ip, pro, pro_code, city, city_code, region, region_code, addr, region_names, err, name, mod_admin_id, mod_phone, mod_username, mod_name, message
     </sql>
 
-    <select id="selectNotNullIp" resultMap="BaseResultMap">
+    <select id="selectNotNullAddr" resultMap="BaseResultMap">
         select id, create_time, modify_time, admin_id, phone, client_id, location, longitude, latitude, country, country_code, username, ip, pro, pro_code, city, city_code, region, region_code, addr, region_names, err, name, mod_admin_id, mod_phone, mod_username, mod_name, message
         from t_location_check
-        where ip is not null
+        where addr is not null
     </select>
 </mapper>

+ 2 - 1
src/main/java/com/szwl/mapper/xml/TNoticeMapper.xml

@@ -10,11 +10,12 @@
         <result column="title" property="title" />
         <result column="note" property="note" />
         <result column="status" property="status" />
+        <result column="company_type" property="companyType" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, create_date, modify_date, title, note, status
+        id, create_date, modify_date, title, note, status, company_type
     </sql>
 
 </mapper>

+ 2 - 1
src/main/java/com/szwl/mapper/xml/TParametersMapper.xml

@@ -12,11 +12,12 @@
         <result column="name" property="name" />
         <result column="val" property="val" />
         <result column="status" property="status" />
+        <result column="material_monitor_status" property="materialMonitorStatus" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, create_date, modify_date, equipment_id, client_id, name, val, status
+        id, create_date, modify_date, equipment_id, client_id, name, val, status, material_monitor_status
     </sql>
 
 </mapper>

+ 28 - 0
src/main/java/com/szwl/model/bean/WeChatTemplateMsg.java

@@ -0,0 +1,28 @@
+package com.szwl.model.bean;
+
+import lombok.Data;
+import lombok.ToString;
+
+@Data
+@ToString
+public class WeChatTemplateMsg {
+    /**
+     * 消息
+     */
+    private String value;
+    /**
+     * 消息颜色
+     */
+    private String color;
+
+
+    public WeChatTemplateMsg(String value) {
+        this.value = value;
+        this.color = "#173177";
+    }
+
+    public WeChatTemplateMsg(String value, String color) {
+        this.value = value;
+        this.color = color;
+    }
+}

+ 4 - 1
src/main/java/com/szwl/model/dto/PromoCodeTarget.java

@@ -4,7 +4,10 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 
 import java.util.Date;
 
-//订单导出
+/**
+ * 国内优惠码导出
+ * @author
+ */
 public class PromoCodeTarget {
 
     /**

+ 57 - 0
src/main/java/com/szwl/model/dto/PromoCodeTargetEn.java

@@ -0,0 +1,57 @@
+package com.szwl.model.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 国外优惠码导出
+ * @author
+ */
+@Data
+public class PromoCodeTargetEn {
+
+    /**
+     * 优惠码
+     */
+    @Excel(name = "Code", width = 20.0D)
+    private Long code;
+
+    /**
+     * 优惠码类型
+     */
+    @Excel(name = "Type", width = 20.0D)
+    private String type;
+
+    /**
+     * 优惠码类型
+     */
+    @Excel(name = "Credit/Discount value", width = 30.0D)
+    private Float discount;
+
+    /**
+     * 所属商家
+     */
+    @Excel(name = "Affiliated merchant", width = 20.0D)
+    private String userName;
+
+    /**
+     * 添加时间
+     */
+    @Excel(name = "Add time", width = 20.0D)
+    private String createDate;
+
+    /**
+     * 状态
+     */
+    @Excel(name = "Status", width = 20.0D)
+    private String isUse;
+
+    /** 使用时间 */
+    @Excel(name = "Usage time", width = 20.0D)
+    private String useDate;
+
+
+    /** 使用机器 */
+    @Excel(name = "Machine used", width = 20.0D)
+    private String useBy;
+}

+ 19 - 2
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -19,7 +19,7 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author wuhs
- * @since 2023-09-26
+ * @since 2024-05-10
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -29,7 +29,6 @@ public class TAdmin implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @TableId(value = "id", type = IdType.AUTO)
-//    @TableId(value = "id", type = IdType.ASSIGN_ID)
     private Long id;
 
     @ApiModelProperty(value = "创建时间")
@@ -148,5 +147,23 @@ public class TAdmin implements Serializable {
     @ApiModelProperty(value = "自定义货币符号")
     private String currencySymbol;
 
+    @ApiModelProperty(value = "DIY功能使用密码")
+    private String diyPassword;
+
+    @ApiModelProperty(value = "微信支付配置ID")
+    private Long wechatPayId;
+
+    @ApiModelProperty(value = "支付宝支付配置ID")
+    private Long alipayId;
+
+    @ApiModelProperty(value = "微信公众号订单通知,0:关闭,1:开启,默认关闭")
+    private String orderNotice;
+
+    @ApiModelProperty(value = "第三方调用API密钥")
+    private String apiKey;
+
+    @ApiModelProperty(value = "是否显示分佣,0:关闭,1:开启,默认开启")
+    private String isDistribution;
+
 
 }

+ 55 - 0
src/main/java/com/szwl/model/entity/TAlarmClean.java

@@ -0,0 +1,55 @@
+package com.szwl.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wuhs
+ * @since 2024-04-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="TAlarmClean对象", description="")
+public class TAlarmClean implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @ApiModelProperty(value = "用户id")
+    private Long adminId;
+
+    @ApiModelProperty(value = "设备id")
+    private Long equipmentId;
+
+    @ApiModelProperty(value = "设备编号")
+    private String clientId;
+
+    @ApiModelProperty(value = "是否海外:0否,1是")
+    private String isOversea;
+
+    @ApiModelProperty(value = "通知电话")
+    private String phone;
+
+    @ApiModelProperty(value = "通知邮箱")
+    private String email;
+
+    @ApiModelProperty(value = "上次通知时间")
+    private Date lastSendTime;
+
+    @ApiModelProperty(value = "本轮做糖数量")
+    private Integer candyNum;
+
+
+}

+ 7 - 1
src/main/java/com/szwl/model/entity/TNotice.java

@@ -1,8 +1,11 @@
 package com.szwl.model.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
 import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -15,7 +18,7 @@ import java.util.Date;
  * </p>
  *
  * @author wuhs
- * @since 2022-11-23
+ * @since 2024-04-16
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -37,5 +40,8 @@ public class TNotice implements Serializable {
 
     private String status;
 
+    @ApiModelProperty(value = "公司平台,0或空为申泽,1为七云")
+    private String companyType;
+
 
 }

+ 3 - 1
src/main/java/com/szwl/model/entity/TParameters.java

@@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author wuhs
- * @since 2022-04-23
+ * @since 2024-02-23
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -46,5 +46,7 @@ public class TParameters implements Serializable {
     @ApiModelProperty(value = "参数类型;0:通用参数;1:进阶参数;2:调试页参数;3:湿度参数")
     private String status;
 
+    @ApiModelProperty(value="物料监控开关,开启为1,关闭为0")
+    private String materialMonitorStatus;
 
 }

+ 22 - 0
src/main/java/com/szwl/model/param/AlarmCleanParam.java

@@ -0,0 +1,22 @@
+package com.szwl.model.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Accessors(chain = true)
+@ApiModel(description = "设备清洗提醒 参数")
+@Data
+public class AlarmCleanParam {
+
+    @ApiModelProperty(value = "是否海外 0不是 1是")
+    private String isOversea;
+
+    @ApiModelProperty(value = "设备编号")
+    private String clientId;
+
+    @ApiModelProperty(value = "做糖数量")
+    private Integer makeCandyNum;
+
+}

+ 263 - 0
src/main/java/com/szwl/model/utils/SampleMail.java

@@ -0,0 +1,263 @@
+package com.szwl.model.utils;
+
+import javax.mail.*;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.Properties;
+import java.util.UUID;
+//import java.util.HashMap;
+//import java.util.Base64;
+//import com.google.gson.GsonBuilder;
+//import javax.activation.DataHandler;
+//import javax.activation.FileDataSource;
+//import java.net.URL;
+//import java.net.URLEncoder;
+//import javax.activation.DataHandler;
+//import javax.activation.URLDataSource;
+
+public class SampleMail {
+    protected static String genMessageID(String mailFrom) {
+        // message-id 必须符合 first-part@last-part
+        String[] mailInfo = mailFrom.split("@");
+        String domain = mailFrom;
+        int index = mailInfo.length - 1;
+        if (index >= 0) {
+            domain = mailInfo[index];
+        }
+        UUID uuid = UUID.randomUUID();
+        StringBuffer messageId = new StringBuffer();
+        messageId.append('<').append(uuid.toString()).append('@').append(domain).append('>');
+        return messageId.toString();
+    }
+
+    public void sendAuthCode(String toEmail, String content) {
+        // 配置发送邮件的环境属性
+        final Properties props = new Properties();
+
+        // 表示SMTP发送邮件,需要进行身份验证
+        props.put("mail.smtp.auth", "true");
+        props.put("mail.smtp.host", "smtpdm.aliyun.com"); //华东1:smtpdm.aliyun.com,悉尼:smtpdm-ap-southeast-2.aliyun.com
+        //设置端口:
+        props.put("mail.smtp.port", "80");//或"25"
+        props.put("mail.smtp.from", "robot@suncee.cn");    //mailfrom 参数
+        props.put("mail.user", "robot@suncee.cn");// 发件人的账号(在控制台创建的发信地址)
+        props.put("mail.password", "DirectMail123");// 发信地址的smtp密码(在控制台选择发信地址进行设置)
+        System.setProperty("mail.mime.splitlongparameters", "false");//用于解决附件名过长导致的显示异常
+
+        // 构建授权信息,用于进行SMTP进行身份验证
+        Authenticator authenticator = new Authenticator() {
+            @Override
+            protected PasswordAuthentication getPasswordAuthentication() {
+                // 用户名、密码
+                String userName = props.getProperty("mail.user");
+                String password = props.getProperty("mail.password");
+                return new PasswordAuthentication(userName, password);
+            }
+        };
+        //使用环境属性和授权信息,创建邮件会话
+        Session mailSession = Session.getInstance(props, authenticator);
+        //mailSession.setDebug(true);//开启debug模式
+
+
+        final String messageIDValue = genMessageID(props.getProperty("mail.user"));
+        //创建邮件消息
+        MimeMessage message = new MimeMessage(mailSession) {
+            @Override
+            protected void updateMessageID() throws MessagingException {
+                //设置自定义Message-ID值
+                setHeader("Message-ID", messageIDValue);//创建Message-ID
+            }
+        };
+
+        try {
+            // 设置发件人邮件地址和名称。填写控制台配置的发信地址。和上面的mail.user保持一致。名称用户可以自定义填写。
+            InternetAddress from = new InternetAddress("robot@suncee.cn", "Cotton Candy Robot");//from 参数,可实现代发,注意:代发容易被收信方拒信或进入垃圾箱。
+            message.setFrom(from);
+
+            //可选。设置回信地址
+            Address[] a = new Address[1];
+            a[0] = new InternetAddress(toEmail);
+            message.setReplyTo(a);
+
+            // 设置收件人邮件地址
+            InternetAddress to = new InternetAddress(toEmail);
+            message.setRecipient(MimeMessage.RecipientType.TO, to);
+
+
+            message.setSentDate(new Date()); //设置时间
+
+            //设置邮件标题
+            message.setSubject("Verification Code");
+            message.setContent(content, "text/html;charset=UTF-8");//html超文本;// "text/plain;charset=UTF-8" //纯文本。
+            // 发送邮件
+            Transport.send(message);
+
+        } catch (MessagingException e) {
+            String err = e.getMessage();
+            // 在这里处理message内容, 格式是固定的
+            System.out.println(err);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+    }
+//    public static void main(String[] args) {
+//        // 配置发送邮件的环境属性
+//        final Properties props = new Properties();
+//
+//        // 表示SMTP发送邮件,需要进行身份验证
+//        props.put("mail.smtp.auth", "true");
+//        props.put("mail.smtp.host", "smtpdm.aliyun.com"); //华东1:smtpdm.aliyun.com,悉尼:smtpdm-ap-southeast-2.aliyun.com,新加坡:smtpdm-ap-southeast-1.aliyuncs.com
+//        //设置端口:
+//        props.put("mail.smtp.port", "80");//或"25", 如果使用ssl,则去掉使用80或25端口的配置,进行如下配置:
+//        //加密方式:
+//        //props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
+//        //props.put("mail.smtp.socketFactory.port", "465");
+//        //props.put("mail.smtp.port", "465");
+//
+//        props.put("mail.smtp.from", "robot@suncee.cn");    //mailfrom 参数
+//        props.put("mail.user", "robot@suncee.cn");// 发件人的账号(在控制台创建的发信地址)
+//        props.put("mail.password", "DirectMail123");// 发信地址的smtp密码(在控制台选择发信地址进行设置)
+//        //props.setProperty("mail.smtp.ssl.enable", "true");  //请配合465端口使用
+//        System.setProperty("mail.mime.splitlongparameters", "false");//用于解决附件名过长导致的显示异常
+//        //props.put("mail.smtp.connectiontimeout", 1000);
+//
+//        // 构建授权信息,用于进行SMTP进行身份验证
+//        Authenticator authenticator = new Authenticator() {
+//            @Override
+//            protected PasswordAuthentication getPasswordAuthentication() {
+//                // 用户名、密码
+//                String userName = props.getProperty("mail.user");
+//                String password = props.getProperty("mail.password");
+//                return new PasswordAuthentication(userName, password);
+//            }
+//        };
+//
+//        //使用环境属性和授权信息,创建邮件会话
+//        Session mailSession = Session.getInstance(props, authenticator);
+//        //mailSession.setDebug(true);//开启debug模式
+//
+//
+//        final String messageIDValue = genMessageID(props.getProperty("mail.user"));
+//        //创建邮件消息
+//        MimeMessage message = new MimeMessage(mailSession) {
+//            @Override
+//            protected void updateMessageID() throws MessagingException {
+//                //设置自定义Message-ID值
+//                setHeader("Message-ID", messageIDValue);//创建Message-ID
+//            }
+//        };
+//
+//        try {
+//            // 设置发件人邮件地址和名称。填写控制台配置的发信地址。和上面的mail.user保持一致。名称用户可以自定义填写。
+//            InternetAddress from = new InternetAddress("robot@suncee.cn", "发件人名称");//from 参数,可实现代发,注意:代发容易被收信方拒信或进入垃圾箱。
+//            message.setFrom(from);
+//
+//            //可选。设置回信地址
+//            Address[] a = new Address[1];
+//            a[0] = new InternetAddress("ritchie@linuxmail.org");
+//            message.setReplyTo(a);
+//
+//            // 设置收件人邮件地址
+//            InternetAddress to = new InternetAddress("ritchie@linuxmail.org");
+//            message.setRecipient(MimeMessage.RecipientType.TO, to);
+//            //如果同时发给多人,才将上面两行替换为如下(因为部分收信系统的一些限制,尽量每次投递给一个人;同时我们限制单次允许发送的人数,具体参考规格清单):
+//            //InternetAddress[] adds = new InternetAddress[2];
+//            //adds[0] = new InternetAddress("收信地址");
+//            //adds[1] = new InternetAddress("收信地址");
+//            //message.setRecipients(Message.RecipientType.TO, adds);
+//
+//            message.setSentDate(new Date()); //设置时间
+////            String ccUser = "抄送地址";
+////            // 设置多个抄送地址
+////            if (null != ccUser && !ccUser.isEmpty()) {
+////                @SuppressWarnings("static-access")
+////                InternetAddress[] internetAddressCC = new InternetAddress().parse(ccUser);
+////                message.setRecipients(Message.RecipientType.CC, internetAddressCC);
+////            }
+////            String bccUser = "密送地址";
+////            // 设置多个密送地址
+////            if (null != bccUser && !bccUser.isEmpty()) {
+////                @SuppressWarnings("static-access")
+////                InternetAddress[] internetAddressBCC = new InternetAddress().parse(bccUser);
+////                message.setRecipients(Message.RecipientType.BCC, internetAddressBCC);
+////            }
+//            //设置邮件标题
+//            message.setSubject("测试主题");
+//            message.setContent("测试<br> 内容", "text/html;charset=UTF-8");//html超文本;// "text/plain;charset=UTF-8" //纯文本。
+//
+////            //若需要开启邮件跟踪服务,请使用以下代码设置跟踪链接头。前置条件和约束见文档"如何开启数据跟踪功能?"
+////            String tagName = "Test";
+////            HashMap<String, String> trace = new HashMap<>();
+////            //这里为字符串"1"
+////            trace.put("OpenTrace", "1");      //打开邮件跟踪
+////            trace.put("LinkTrace", "1");     //点击邮件里的URL跟踪
+////            trace.put("TagName", tagName);   //控制台创建的标签tagname
+////            String jsonTrace = new GsonBuilder().setPrettyPrinting().create().toJson(trace);
+////            //System.out.println(jsonTrace);
+////            String base64Trace = new String(Base64.getEncoder().encode(jsonTrace.getBytes()));
+////            //设置跟踪链接头
+////            message.addHeader("X-AliDM-Trace", base64Trace);
+////            //邮件eml原文中的示例值:X-AliDM-Trace: eyJUYWdOYW1lIjoiVGVzdCIsIk9wZW5UcmFjZSI6IjEiLCJMaW5rVHJhY2UiOiIxIn0=
+//
+////发送附件和内容:
+////            BodyPart messageBodyPart = new MimeBodyPart();
+////            //messageBodyPart.setText("消息<br>Text");//设置邮件的内容,文本
+////            messageBodyPart.setContent("测试<br> 内容", "text/html;charset=UTF-8");// 纯文本:"text/plain;charset=UTF-8" //设置邮件的内容
+////            //创建多重消息
+////            Multipart multipart = new MimeMultipart();
+////            //设置文本消息部分
+////            multipart.addBodyPart(messageBodyPart);
+//
+////            //附件部分
+////            //发送附件,总的邮件大小不超过15M,创建消息部分。
+//            //发送本地附件
+////            String[] fileList = new String[2];
+////            fileList[0] = "C:\\Users\\test1.txt";
+////            fileList[1] = "C:\\Users\\test2.txt";
+////            for (int index = 0; index < fileList.length; index++) {
+////                MimeBodyPart mimeBodyPart = new MimeBodyPart();
+////                //            //设置要发送附件的文件路径
+////                FileDataSource filesdata = new FileDataSource(fileList[index]);
+////                mimeBodyPart.setDataHandler(new DataHandler(filesdata));
+////                //处理附件名称中文(附带文件路径)乱码问题
+////                mimeBodyPart.setFileName(MimeUtility.encodeWord("自定义附件名.xlsx"));
+////                mimeBodyPart.addHeader("Content-Transfer-Encoding", "base64");
+////                multipart.addBodyPart(mimeBodyPart);
+////            }
+//
+//
+//            //发送URL附件
+////            String[] fileList = new String[2];
+////            fileList[0] = "https://example.oss-cn-shanghai.aliyuncs.com/xxxxxxxxxxx1.png";
+////            fileList[1] = "https://example.oss-cn-shanghai.aliyuncs.com/xxxxxxxxxxx2.png";
+////            for  (int index = 0; index < fileList.length; index++) {
+////                String encode = URLEncoder.encode(fileList[index], "UTF-8");
+////                MimeBodyPart mimeBodyPart = new MimeBodyPart();
+////                mimeBodyPart.setDataHandler(new DataHandler(new URLDataSource(new URL(encode.replace("%3A",":").replace("%2F","/")))));
+////                mimeBodyPart.setFileName(MimeUtility.encodeText("自定义附件名.xlsx"));
+////                multipart.addBodyPart(mimeBodyPart);
+////            }
+//
+//
+////            //发送含有附件的完整消息
+////            message.setContent(multipart);
+////            // 发送附件代码,结束
+//
+//            // 发送邮件
+//            Transport.send(message);
+//
+//        } catch (MessagingException e) {
+//            String err = e.getMessage();
+//            // 在这里处理message内容, 格式是固定的
+//            System.out.println(err);
+//        } catch (UnsupportedEncodingException e) {
+//            // TODO Auto-generated catch block
+//            e.printStackTrace();
+//        } //catch (MalformedURLException e) {
+//        //    e.printStackTrace();
+//        //}
+//    }
+}

+ 30 - 0
src/main/java/com/szwl/service/TAlarmCleanService.java

@@ -0,0 +1,30 @@
+package com.szwl.service;
+
+import com.szwl.model.entity.TAlarmClean;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wuhs
+ * @since 2024-04-26
+ */
+public interface TAlarmCleanService extends IService<TAlarmClean> {
+
+    /**
+     * 判断是否满足条件
+     */
+//    boolean sendOrNo();
+
+    /**
+     * 发送邮件
+     */
+    void sendEmail(String email, String clientId);
+
+    /**
+     * 发送短信
+     */
+    String sendNote(String phone, String clientId);
+}

+ 16 - 3
src/main/java/com/szwl/service/TEquipmentService.java

@@ -18,13 +18,26 @@ public interface TEquipmentService extends MyIService<TEquipment> {
     /**
      * 发送信息,1:个推,2:MQ
      */
-    public String sentMessage(String clientId,String json);
+    String sentMessage(String clientId,String json);
 
-    public String findMachineTotalNum(StatisticsParam param);
+    String findMachineTotalNum(StatisticsParam param);
 
-    public String findMachineUseNum(StatisticsParam param);
+    String findMachineUseNum(StatisticsParam param);
+    String findMachineUseNumAdmin(StatisticsParam param);
 
     Optional<String> syncOneEquipmentByClientId(String clientId);
 
     int getForeignEquipmentCount(String area); // 0 国内,1 海外,2 全球
+
+    /**
+     * 检查设备
+     */
+    void checkEquipmentStatus();
+
+    /**
+     * 通知客户重置花型价格
+     * @param adminId
+     * @param deviceId
+     */
+    void informClient(Long adminId, String deviceId);
 }

+ 2 - 0
src/main/java/com/szwl/service/TMessageCodeService.java

@@ -24,5 +24,7 @@ public interface TMessageCodeService extends MyIService<TMessageCode> {
      * */
     String sentEmail(String type, String email);
 
+    String sendEmailAbroad(String type, String email);
+
     Date getLastSendTime(String phoneOrEmail);
 }

+ 1 - 1
src/main/java/com/szwl/service/TParametersService.java

@@ -9,7 +9,7 @@ import com.szwl.service.base.MyIService;
  * </p>
  *
  * @author wuhs
- * @since 2022-04-23
+ * @since 2024-02-23
  */
 public interface TParametersService extends MyIService<TParameters> {
 

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

@@ -1,6 +1,7 @@
 package com.szwl.service;
 
 import com.szwl.model.dto.PromoCodeTarget;
+import com.szwl.model.dto.PromoCodeTargetEn;
 import com.szwl.model.entity.TPromoCode;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -17,4 +18,6 @@ import java.util.List;
 public interface TPromoCodeService extends IService<TPromoCode> {
 
     List<PromoCodeTarget> findById(List<TPromoCode> list);
+
+    List<PromoCodeTargetEn> exportPromoCode(List<TPromoCode> list);
 }

+ 42 - 0
src/main/java/com/szwl/service/TWechatService.java

@@ -3,6 +3,8 @@ package com.szwl.service;
 import com.szwl.model.entity.TWechat;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Date;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,44 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TWechatService extends IService<TWechat> {
 
+    /**
+     * 异常离线通知
+     * @param openId
+     * @param clientId
+     * @param name
+     * @param ifForeign
+     * @param companyType
+     * @return
+     */
+    void sendNetworkMessage(String openId, String clientId, String name, String ifForeign, String companyType);
+
+    /**
+     * 异常报警通知
+     * @param openId
+     * @param clientId
+     * @param name
+     * @param companyType
+     * @param alarmContent
+     * @param occurrenceTime
+     * @return
+     */
+     void sendAlarmMessage(String openId, String clientId, String name, String companyType, String alarmContent, Date occurrenceTime);
+
+    /**
+     * 获取access_token
+     * @param companyType
+     * @return
+     */
+     String getAccessToken(String companyType);
+
+    /**
+     * 发送设备上下线通知
+     * @param openId
+     * @param clientId
+     * @param networkTime
+     * @param companyType
+     * @param name
+     * @param eqeStatus
+     */
+    void sendOnOffMessage(String openId, String clientId, String networkTime, String companyType, String name, Integer eqeStatus);
 }

+ 69 - 0
src/main/java/com/szwl/service/impl/TAlarmCleanServiceImpl.java

@@ -0,0 +1,69 @@
+package com.szwl.service.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.szwl.model.entity.TAlarmClean;
+import com.szwl.mapper.TAlarmCleanMapper;
+import com.szwl.model.utils.MailUtil;
+import com.szwl.model.utils.SampleMail;
+import com.szwl.model.utils.YunPianSms;
+import com.szwl.service.TAlarmCleanService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author wuhs
+ * @since 2024-04-26
+ */
+@Service
+public class TAlarmCleanServiceImpl extends ServiceImpl<TAlarmCleanMapper, TAlarmClean> implements TAlarmCleanService {
+
+    private static final String appid = "07784f5fedb508046c841b391005b7de";
+
+    public String getContent(String clientId) {
+        StringBuffer content = new StringBuffer();
+
+        String str = "Dear customer:<br>" +
+                "<br>" +
+                "Your machine number is <" + clientId + "> marshmallow robot, the stove maintenance cycle has arrived, please clean the stove cover to keep the pattern in the best condition, if it has been cleaned, please ignore this reminder." +
+                "<br>" +
+                "<br>" +
+                "Best Regards.<br>" +
+                "Sunzee Intelligent";;
+        content.append(str);
+        return content.toString();
+    }
+
+    @Override
+    public void sendEmail(String email, String clientId) {
+        String content = "";
+        content = getContent(clientId);
+        String subject = "Cleaning reminders";
+        new MailUtil().send(email, subject, content);
+    }
+
+    @Override
+    public String sendNote(String phone, String clientId) {
+        String msg = null;
+        try {
+            String result = YunPianSms.sendSms(appid, getAlarmCleanMessage(clientId), phone);
+            ObjectMapper om = new ObjectMapper();
+            JsonNode jsonNode = om.readTree(result);
+            msg = jsonNode.get("msg").asText();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return phone + ": " + msg;
+    }
+
+
+    private String getAlarmCleanMessage(String clientId) {
+        return "【申泽智能】您机器编号为 " + clientId + " 的棉花糖机器人,炉头保养周期已到,请清洁炉头盖,以保持花型在最佳状态,如已清洁请忽略本提醒。";
+    }
+}

+ 1 - 1
src/main/java/com/szwl/service/impl/TEquipmentDeletedServiceImpl.java

@@ -19,7 +19,7 @@ import javax.annotation.Resource;
  * @since 2023-03-31
  */
 @Service
-public class TEquipmentDeletedServiceImpl  extends ServiceImpl<TEquipmentDeletedMapper, TEquipmentDeleted> implements TEquipmentDeletedService {
+public class TEquipmentDeletedServiceImpl extends ServiceImpl<TEquipmentDeletedMapper, TEquipmentDeleted> implements TEquipmentDeletedService {
 
     @Resource
     private TEquipmentDeletedMapper tEquipmentDeletedMapper;

+ 169 - 4
src/main/java/com/szwl/service/impl/TEquipmentServiceImpl.java

@@ -7,11 +7,16 @@ import com.szwl.model.bo.R;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TEquipment;
 import com.szwl.mapper.TEquipmentMapper;
+import com.szwl.model.entity.TWechat;
 import com.szwl.model.query.StatisticsParam;
+import com.szwl.model.utils.MailUtil;
 import com.szwl.model.utils.PushUtils;
+import com.szwl.model.utils.YunPianSms;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TEquipmentService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.szwl.service.TWechatService;
+import com.szwl.util.WechatSendUtil;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.amqp.core.AmqpTemplate;
 import org.springframework.amqp.core.MessageProperties;
@@ -19,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.util.Date;
 import java.util.List;
 import java.util.Optional;
@@ -34,17 +40,27 @@ import java.util.stream.Collectors;
  */
 @Service
 public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipment> implements TEquipmentService {
+
     @Autowired
     private AmqpTemplate amqpTemplate;
+
     @Resource
     TEquipmentMapper tEquipmentMapper;
+
     @Autowired
     TAdminService adminService;
+
     @Resource
     SyncOldFeign syncOldFeign;
+
     @Resource
     TEquipmentService equipmentService;
 
+    @Resource
+    TWechatService wechatService;
+
+    private static final String appid = "07784f5fedb508046c841b391005b7de";
+
     @Override
     public String sentMessage(String clientId, String json) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
@@ -85,6 +101,11 @@ public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipm
     }
 
     @Override
+    public String findMachineUseNumAdmin(StatisticsParam param) {
+        return tEquipmentMapper.findMachineUseNumAdmin(param);
+    }
+
+    @Override
     public Optional<String> syncOneEquipmentByClientId(String clientId) {
         if (StringUtils.isNotEmpty(clientId)) {
             TEquipment oldEquipment = R.getDataIfSuccess(syncOldFeign.getEquipmentByClientId(clientId));
@@ -241,10 +262,154 @@ public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipm
         }
     }
 
-//    @Override
-//    public Integer insertBatchSomeColumn(List<TEquipment> entityList) {
-//        return tEquipmentMapper.insertBatchSomeColumn(entityList);
-//    }
+    @Override
+    public void checkEquipmentStatus() {
+        LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+        query.eq(TEquipment::getEqeStatus, 1);
+        List<TEquipment> equipmentList = equipmentService.list(query);
+        if (equipmentList.size() > 0) {
+            // 获取当前时间,并检查设备状态是否过期
+            long nowTime = System.currentTimeMillis();
+            for (TEquipment equipment : equipmentList) {
+                if (equipment.getModifyDate() != null) {
+                    // 如果设备的最后刷新时间超过480秒前,则清除设备状态信息,更改为关机状态
+                    long updateTime = equipment.getModifyDate().getTime();
+                    if (nowTime > updateTime && (nowTime - updateTime) > 720000) {
+                        equipment.setCabinetTm("");
+                        equipment.setCabinetHd("");
+                        equipment.setFurnaceTm("");
+                        equipment.setFurnaceSp("");
+                        equipment.setEqeStatus(0);
+                        equipmentService.updateById(equipment);
+                        // 说明机器没有上传信号,判断为网络不好或者关机,发送信号通知客户 查机器归属国内还是国外
+                        TAdmin admin = adminService.getById(equipment.getAdminId());
+                        String ifForeign = admin.getIfForeign();
+                        // 查询是申泽还是七云的
+                        String companyType = admin.getCompanyType();
+                        LambdaQueryWrapper<TWechat> wechatQuery = Wrappers.lambdaQuery();
+                        wechatQuery.eq(TWechat::getAdminId, equipment.getAdminId());
+                        TWechat wechat = wechatService.getOne(wechatQuery);
+                        // 设备名称
+                        String name = equipment.getName();
+                        // 如果为空就拿设备编号后六位
+                        if(StringUtils.isEmpty(name)) {
+                            name = equipment.getClientId().substring(equipment.getClientId().length() - 6);
+                        }
+                        if(wechat != null) {
+                            // 有绑定微信的话发公众号
+                            String openId = wechat.getOpenId();
+                            wechatService.sendNetworkMessage(openId,equipment.getClientId(),name, ifForeign, companyType);
+                            if (ifForeign.equals("1")) {
+                                // 国外再发邮件
+                                String messageReceiver = equipment.getMessageReceiver();
+                                if(StringUtils.isNotEmpty(messageReceiver)) {
+                                    String[] split = messageReceiver.split(",");
+                                    for (String s : split) {
+                                        WechatSendUtil.sentEmail(s, name);
+                                    }
+                                } else {
+                                    if(StringUtils.isNotEmpty(admin.getEmail())){
+                                        WechatSendUtil.sentEmail(admin.getEmail(), name);
+                                    }
+                                }
+                            }
+                        } else {
+                            // 0或空:国内,1:国外
+                            if (ifForeign.equals("0") || ifForeign.equals("")) {
+                                //TODO 国内发短信
+                            } else {
+                                // 国外发送邮件
+                                String messageReceiver = equipment.getMessageReceiver();
+                                if(StringUtils.isNotEmpty(messageReceiver)) {
+                                    String[] split = messageReceiver.split(",");
+                                    for (String s : split) {
+                                        WechatSendUtil.sentEmail(s, name);
+                                    }
+                                } else {
+                                    if(StringUtils.isNotEmpty(admin.getEmail())){
+                                        WechatSendUtil.sentEmail(admin.getEmail(), name);
+                                    }
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public void informClient(Long adminId, String deviceId) {
+        LambdaQueryWrapper<TAdmin> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(TAdmin::getId, adminId);
+        TAdmin admin = adminService.getOne(queryWrapper);
+        String ifForeign = admin.getIfForeign();
+        String phone = admin.getPhone();
+        String email = admin.getEmail();
+        switch (ifForeign) {
+            case "0": { // 国内发短信
+                if (StringUtils.isEmpty(phone)) {
+                    return;
+                }
+                try {
+                    String sms = YunPianSms.sendSms(appid, getInformText(deviceId), phone);
+                    System.out.println("短信已发送:" + sms);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+                break;
+            }
+            case "1": { // 海外发邮箱
+                if (StringUtils.isEmpty(email)) {
+                    return;
+                }
+                String subject = "Reset the price of the flowers"; // 邮件标题
+                String content = getInformContent(deviceId); // 邮件正文
+                new MailUtil().send(email, subject, content);
+                break;
+            }
+            default:
+                System.out.println("无效的ifForeign");
+                break;
+        }
+    }
+
+    private String getInformContent(String deviceId) {
+        String content;
+        String str = "Dear customer:<br>" +
+                "<br>" +
+                "Your machine number is <" + deviceId + "> cotton candy machine, the number of flowers has been pushed, please reset the price of the flowers!" +
+                "<br>" +
+                "<br>" +
+                "Best Regards.<br>" +
+                "Sunzee Intelligent";
+        content = String.format(str);
+        return content;
+    }
 
+    private String getInformText(String deviceId) {
+        String sms = "";
+        if(StringUtils.isNotEmpty(deviceId)){
+            sms = "【申泽智能】您好,您名下设备编号为" + deviceId + "的机器,花型数量已推送,请重新设置价格!";
+        }
+        return sms;
+    }
 
+    /**
+     * 根据经度获取时区
+     * @param currentLon 当前经度
+     * @return
+     */
+    public static int lateTimeZone(double currentLon) {
+        int timeZone ;
+        int shangValue = (int)(currentLon / 15);
+        double yushuValue =  Math.abs(currentLon % 15);
+        if (yushuValue <= 7.5) {
+            timeZone = shangValue;
+        } else {
+            timeZone = shangValue +(currentLon > 0 ?  1 :-1);
+        }
+        return timeZone;
+    }
 }

+ 2 - 2
src/main/java/com/szwl/service/impl/THuifuMchServiceImpl.java

@@ -250,7 +250,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
             // 结算周期
             settleConfig.put("settle_status", "1");
         }
-        settleConfig.put("settle_cycle", "D1");
+        settleConfig.put("settle_cycle", "T1");
         request.put("settle_config", settleConfig);
 
         // 签名:sign
@@ -475,7 +475,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         // 营业执照有效期类型,0:非长期有效 ,1:长期有效
         request.put("license_validity_type", tHuifuMchCheck.getLicenseValidityType());
         // 营业执照有效期开始日期
-        request.put("license_begin_date", "20151208");
+        request.put("license_begin_date", tHuifuMchCheck.getLicenseBeginDate());
         // 营业执照有效期截止日期
         if (StrUtil.isNotEmpty(tHuifuMchCheck.getLicenseEndDate())) {
             request.put("license_end_date", tHuifuMchCheck.getLicenseEndDate());

+ 2 - 2
src/main/java/com/szwl/service/impl/TJoinpayMchServiceImpl.java

@@ -779,8 +779,8 @@ public class TJoinpayMchServiceImpl extends ServiceImpl<TJoinpayMchMapper, TJoin
 
         String url = "https://www.joinpay.com/allocFunds";
         JSONObject requestData = new JSONObject(new LinkedHashMap());
-        requestData.put("alt_login_name", "test1_" + mch.getAdminId() + "@mianhuatang.com");
-
+//        requestData.put("alt_login_name", "test1_" + mch.getAdminId() + "@mianhuatang.com");
+        requestData.put("alt_login_name", mch.getLoginName());
 
         JSONObject requestJson = new JSONObject(new TreeMap<String, Object>());
         requestJson.put("method", "altmch.query");

+ 30 - 65
src/main/java/com/szwl/service/impl/TLocationCheckServiceImpl.java

@@ -1,12 +1,5 @@
 package com.szwl.service.impl;
 
-import cn.hutool.http.HttpUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.szwl.model.bo.R;
 import com.szwl.model.entity.TLocationCheck;
 import com.szwl.mapper.TLocationCheckMapper;
 import com.szwl.model.utils.YunPianSms;
@@ -15,13 +8,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import java.io.IOException;
-import java.util.Objects;
+import java.util.StringTokenizer;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author wuhs
@@ -30,29 +22,15 @@ import java.util.Objects;
 @Service
 public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper, TLocationCheck> implements TLocationCheckService {
 
-//    TLocationCheckService locationCheckService;
-//
-//    public TLocationCheckServiceImpl(TLocationCheckService locationCheckService) {
-//        this.locationCheckService = locationCheckService;
-//    }
-
     private static final String appid = "07784f5fedb508046c841b391005b7de";
 
     @Override
     public String locCheckNoMsg(TLocationCheck locationCheck, String clientId, String addr) {
-        String location = locationCheck.getLocation();
         String country = locationCheck.getCountry();
         if (StringUtils.isEmpty(country)) {
             return "国家不能为空";
         }
-        // 如果 pro,city,addr 中都不包含 country 或者 location,就是异常,发短信通知
-        boolean containsUserInput = true;
-        // location 为空 / 不为空
-        if (StringUtils.isEmpty(location)) {
-            containsUserInput = addr.contains(country);
-        } else {
-            containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
-        }
+        boolean containsUserInput = isAddressInCountryList(addr, country);
 
         if (!containsUserInput) { // 不包含,发短信通知,并拒绝审核
             return "fail";
@@ -63,68 +41,51 @@ public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper,
     @Override
     public String locCheckMsg(TLocationCheck locationCheck, String clientId, String addr) throws IOException {
 
-        String location = locationCheck.getLocation();
         String country = locationCheck.getCountry();
 
         if (StringUtils.isEmpty(country)) {
             return "国家不能为空";
         }
-//        ObjectMapper objectMapper = new ObjectMapper();
-//        JsonNode jsonNode = objectMapper.readTree(s);
-//        String addr = jsonNode.get("addr").asText();
-
-        // 如果 pro,city,addr 中都不包含 country 或者 location,就是异常,发短信通知
-        boolean containsUserInput = true;
-        // location 为空 / 不为空
-        // country 是中国 / 不是中国
-        if (StringUtils.isEmpty(location)) {
-            if (country.equals("中国")) {
-                return "国内必须精确到省市";
-            } else {
-                containsUserInput = addr.contains(country);
-            }
-        } else {
-            if (country.equals("中国")) {
-                containsUserInput = addr.contains(location);
-            } else {
-                containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
-            }
-        }
+
+        boolean containsUserInput = isAddressInCountryList(addr, country);
 
         String phone = "18620242721";
+//        String phone1 = "13631231970"; // 基哥
+        String phone2 = "15018460394"; // 龙
+
         String messages = "【申泽部门】设备编号:" + clientId + ",所在ip与设定位置不符,请及时查看。";
         if (!containsUserInput) { // 不包含,发短信通知,并拒绝审核
             YunPianSms.sendSms(appid, messages, phone);
+            YunPianSms.sendSms(appid, messages, phone2);
             return "fail";
         }
         return "success";
     }
 
+    public static boolean isAddressInCountryList(String addr, String country) {
+        // 使用StringTokenizer分割国家字符串
+        StringTokenizer tokenizer = new StringTokenizer(country, "、");
+
+        // 循环遍历国家列表
+        while (tokenizer.hasMoreTokens()) {
+            String singleCountry = tokenizer.nextToken();
+            // 如果地址包含当前国家,则返回true
+            if (addr.contains(singleCountry)) {
+                return true;
+            }
+        }
+        // 如果没有找到匹配的国家,则返回false
+        return false;
+    }
+
     @Override
     public String schLocCheck(TLocationCheck locationCheck, String clientId, String addr) {
-        String location = locationCheck.getLocation();
         String country = locationCheck.getCountry();
 
         if (StringUtils.isEmpty(country)) {
             return "国家不能为空";
         }
-
-        boolean containsUserInput = true;
-        // location 为空 / 不为空
-        // country 是中国 / 不是中国
-        if (StringUtils.isEmpty(location)) {
-            if (country.equals("中国")) {
-                return "国内必须精确到省";
-            } else {
-                containsUserInput = addr.contains(country);
-            }
-        } else {
-            if (country.equals("中国")) {
-                containsUserInput = addr.contains(location);
-            } else {
-                containsUserInput = addr.contains(country) || addr.contains(location) || location.contains(addr);
-            }
-        }
+        boolean containsUserInput = isAddressInCountryList(addr, country);
 
         if (!containsUserInput) { // 不包含,返回设备编号
             return "{" + clientId + "}";
@@ -136,8 +97,12 @@ public class TLocationCheckServiceImpl extends ServiceImpl<TLocationCheckMapper,
     @Override
     public void schSendMsg(String locErrorEq) throws IOException {
         String phone = "18620242721";
+//        String phone1 = "13631231970"; // 基哥
+        String phone2 = "15018460394"; // 龙
         String messages = "【申泽部门】设备编号:" + locErrorEq + ",所在ip与设定位置不符,请及时查看。";
         YunPianSms.sendSms(appid, messages, phone);
+//        YunPianSms.sendSms(appid, messages, phone1);
+        YunPianSms.sendSms(appid, messages, phone2);
     }
 
 

+ 19 - 1
src/main/java/com/szwl/service/impl/TMessageCodeServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.szwl.model.entity.TMessageCode;
 import com.szwl.mapper.TMessageCodeMapper;
 import com.szwl.model.utils.MailUtil;
+import com.szwl.model.utils.SampleMail;
 import com.szwl.model.utils.YunPianSms;
 import com.szwl.service.TMessageCodeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -79,7 +80,24 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
         tMessageCode.setCreateDate(new Date());
         tMessageCode.setStatus("0");
         tMessageCodeMapper.insert(tMessageCode);
-        return "发送成功Success";
+        return "发送成功";
+    }
+
+    @Override
+    public String sendEmailAbroad(String type, String email) {
+        String code = addCode();
+        String contnet = "";
+        contnet = getContnet(type,code);
+        new SampleMail().sendAuthCode(email, contnet);
+        TMessageCode tMessageCode = new TMessageCode();
+        tMessageCode.setType(type);
+        tMessageCode.setCode(code);
+        tMessageCode.setPhone(email);
+        tMessageCode.setModifyDate(new Date());
+        tMessageCode.setCreateDate(new Date());
+        tMessageCode.setStatus("0");
+        tMessageCodeMapper.insert(tMessageCode);
+        return "Send Success";
     }
 
     @Override

+ 1 - 1
src/main/java/com/szwl/service/impl/TParametersServiceImpl.java

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
  * </p>
  *
  * @author wuhs
- * @since 2022-04-23
+ * @since 2024-02-23
  */
 @Service
 public class TParametersServiceImpl extends ServiceImpl<TParametersMapper, TParameters> implements TParametersService {

+ 32 - 0
src/main/java/com/szwl/service/impl/TPromoCodeServiceImpl.java

@@ -1,6 +1,7 @@
 package com.szwl.service.impl;
 
 import com.szwl.model.dto.PromoCodeTarget;
+import com.szwl.model.dto.PromoCodeTargetEn;
 import com.szwl.model.entity.TPromoCode;
 import com.szwl.mapper.TPromoCodeMapper;
 import com.szwl.model.utils.DateUtils;
@@ -53,4 +54,35 @@ public class TPromoCodeServiceImpl extends ServiceImpl<TPromoCodeMapper, TPromoC
 
         return promoCodeTargets;
     }
+
+    @Override
+    public List<PromoCodeTargetEn> exportPromoCode(List<TPromoCode> list) {
+        List<PromoCodeTargetEn> promoCodeTargetEns = new ArrayList<>();
+        for(TPromoCode promoCode : list){
+            PromoCodeTargetEn promoCodeTargetEn = new PromoCodeTargetEn();
+            promoCodeTargetEn.setCode(promoCode.getCode());
+            if(StringUtils.isNotEmpty(promoCode.getType()) && promoCode.getType().equals("1")){
+                promoCodeTargetEn.setType("Deduction voucher");
+            }else {
+                promoCodeTargetEn.setType("Discount coupon");
+            }
+            promoCodeTargetEn.setDiscount(promoCode.getDiscount());
+            // 格式化时间
+            if(promoCode.getCreateDate()!=null) {
+                String formatPayDate = DateUtils.formatDate(promoCode.getCreateDate(), DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss);
+                promoCodeTargetEn.setCreateDate(formatPayDate);
+            }
+            if(promoCode.getIsUse().equals("0")){
+                promoCodeTargetEn.setIsUse("Not used");
+            }else {
+                promoCodeTargetEn.setIsUse("Used");
+            }
+            promoCodeTargetEn.setUseBy(promoCode.getUseBy());
+            promoCodeTargetEn.setUseDate(promoCode.getUseDate());
+            promoCodeTargetEn.setUserName(promoCode.getUserName());
+            promoCodeTargetEns.add(promoCodeTargetEn);
+        }
+
+        return promoCodeTargetEns;
+    }
 }

+ 252 - 0
src/main/java/com/szwl/service/impl/TWechatServiceImpl.java

@@ -1,10 +1,34 @@
 package com.szwl.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.szwl.constant.ConfigConsts;
+import com.szwl.model.bean.WeChatTemplateMsg;
+import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TWechat;
 import com.szwl.mapper.TWechatMapper;
+import com.szwl.service.TAdminService;
 import com.szwl.service.TWechatService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * <p>
@@ -14,7 +38,235 @@ import org.springframework.stereotype.Service;
  * @author wuhs
  * @since 2023-05-22
  */
+@Slf4j
 @Service
 public class TWechatServiceImpl extends ServiceImpl<TWechatMapper, TWechat> implements TWechatService {
 
+    @Autowired
+    TAdminService adminService;
+
+    @Autowired
+    private StringRedisTemplate redisTemplate;
+
+    private static final String SZ_ACCESS_TOKEN_KEY = "sz_wechat_access_token";
+    private static final String SC_ACCESS_TOKEN_KEY = "sc_wechat_access_token";
+
+    /**
+     * 缓存1个半小时(90分钟)
+     */
+    private static final long EXPIRATION_TIME = 90 * 60;
+
+
+    @Override
+    public void sendNetworkMessage(String openId, String clientId, String name, String ifForeign, String companyType) {
+        // 模板参数
+        Map<String, WeChatTemplateMsg> sendMag = new HashMap();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String alarmTime = format.format(new Date());
+        if(name.length() > 20) {
+            name =  name.substring(0, 16) + "...";
+        }
+        if (StringUtils.isEmpty(ifForeign) || ifForeign.equals("0")) {
+            // 国内
+            sendMag.put("thing11", new WeChatTemplateMsg(name));
+            sendMag.put("character_string14", new WeChatTemplateMsg(clientId.substring(clientId.length()-6)));
+            sendMag.put("thing4", new WeChatTemplateMsg("严重"));
+            sendMag.put("time5", new WeChatTemplateMsg(alarmTime));
+            sendMag.put("thing6", new WeChatTemplateMsg("机器可能出现断网或突然断电,请及时处理!"));
+        } else {
+            // 国外
+            sendMag.put("thing11", new WeChatTemplateMsg(name));
+            sendMag.put("character_string14", new WeChatTemplateMsg(clientId.substring(clientId.length()-6)));
+            sendMag.put("thing4", new WeChatTemplateMsg("Serious"));
+            sendMag.put("time5", new WeChatTemplateMsg(alarmTime));
+            sendMag.put("thing6", new WeChatTemplateMsg("Power/Network loss."));
+        }
+        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+            sendWechatMessage(openId, sendMag, companyType, ConfigConsts.SZ_TEMPLATE_ID);
+        } else {
+            sendWechatMessage(openId, sendMag, companyType, ConfigConsts.SC_TEMPLATE_ID);
+        }
+    }
+
+    @Override
+    public void sendAlarmMessage(String openId, String clientId, String name, String companyType, String alarmContent, Date occurrenceTime) {
+        // 模板参数
+        Map<String, WeChatTemplateMsg> sendMag = new HashMap();
+        // 转换时间为String类型
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String alarmTime = format.format(occurrenceTime);
+        // 模版参数
+        if(name.length() > 20) {
+            sendMag.put("thing11", new WeChatTemplateMsg(name.substring(0, 16) + "..."));
+        } else {
+            sendMag.put("thing11", new WeChatTemplateMsg(name));
+        }
+        sendMag.put("character_string14", new WeChatTemplateMsg(clientId.substring(clientId.length()-6)));
+        sendMag.put("thing4", new WeChatTemplateMsg("高"));
+        sendMag.put("time5", new WeChatTemplateMsg(alarmTime));
+        sendMag.put("thing6", new WeChatTemplateMsg(alarmContent));
+        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+            sendWechatMessage(openId, sendMag, companyType, ConfigConsts.SZ_TEMPLATE_ID);
+        } else {
+            sendWechatMessage(openId, sendMag, companyType, ConfigConsts.SC_TEMPLATE_ID);
+        }
+    }
+
+    @Override
+    public String getAccessToken(String companyType) {
+        String url= "";
+        String accessToken = "";
+        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+            url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+                    + ConfigConsts.SZ_WX_SUB_APP_ID + "&secret=" + ConfigConsts.SZ_WX_APP_SECRET;
+            TAdmin admin = adminService.getById(2738L);
+            admin.setApiKey(accessToken);
+            adminService.updateById(admin);
+        } else {
+            url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+                    + ConfigConsts.SC_WX_SUB_APP_ID + "&secret=" + ConfigConsts.SC_WX_APP_SECRET;
+            TAdmin admin = adminService.getById(2739L);
+            admin.setApiKey(accessToken);
+            adminService.updateById(admin);
+        }
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String line;
+        StringBuffer stringBuffer = new StringBuffer();
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+
+            // 设置通用的请求属性 设置请求格式
+            //设置返回类型
+            conn.setRequestProperty("contentType", "text/plain");
+            //设置请求类型
+            conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
+            //设置超时时间
+            conn.setConnectTimeout(1000);
+            conn.setReadTimeout(1000);
+            conn.setDoOutput(true);
+            conn.connect();
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应    设置接收格式
+            in = new BufferedReader(
+                    new InputStreamReader(conn.getInputStream(), "UTF-8"));
+            while ((line = in.readLine()) != null) {
+                stringBuffer.append(line);
+            }
+            JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
+            log.info("获取token:{}",jsonObject.toString());
+            accessToken = jsonObject.getString("access_token");
+            if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+                TAdmin admin = adminService.getById(2738L);
+                admin.setApiKey(accessToken);
+                adminService.updateById(admin);
+            } else {
+                TAdmin admin = adminService.getById(2739L);
+                admin.setApiKey(accessToken);
+                adminService.updateById(admin);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            //使用finally块来关闭输出流、输入流
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return accessToken;
+    }
+
+    @Override
+    public void sendOnOffMessage(String openId, String clientId, String networkTime, String companyType, String name, Integer eqeStatus) {
+        // 模板参数
+        Map<String, WeChatTemplateMsg> sendMag = new HashMap();
+        // 转换时间为String类型
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Long time = Long.valueOf(networkTime);
+        String workTime = format.format(time);
+        clientId = clientId.substring(clientId.length() - 6);
+        // 模版参数
+        if(name.length() > 20) {
+            sendMag.put("thing2", new WeChatTemplateMsg(name.substring(0, 16) + "..."));
+        } else {
+            sendMag.put("thing2", new WeChatTemplateMsg(name));
+        }
+        if (eqeStatus == 1) {
+            sendMag.put("character_string9", new WeChatTemplateMsg(clientId));
+        } else {
+            sendMag.put("thing6", new WeChatTemplateMsg(clientId));
+        }
+        sendMag.put("time4", new WeChatTemplateMsg(workTime));
+        String templateId = "";
+        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+            if(eqeStatus == 1) {
+                templateId = ConfigConsts.SZ_ON_TEMPLATE_ID;
+            } else {
+                templateId = ConfigConsts.SZ_OFF_TEMPLATE_ID;
+            }
+        } else {
+            if(eqeStatus == 1) {
+                templateId = ConfigConsts.SC_ON_TEMPLATE_ID;
+            } else {
+                templateId = ConfigConsts.SC_OFF_TEMPLATE_ID;
+            }
+        }
+        sendWechatMessage(openId, sendMag, companyType, templateId);
+    }
+
+    /**
+     * 获取accessToken推送消息
+     * @param openId
+     * @param sendMag
+     * @param companyType
+     * @return
+     */
+    public void sendWechatMessage(String openId, Map<String, WeChatTemplateMsg> sendMag, String companyType, String templateId) {
+        String accessToken = "";
+        try {
+            if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+                TAdmin admin = adminService.getById(2738L);
+                accessToken = admin.getApiKey();
+            } else {
+                TAdmin admin = adminService.getById(2739L);
+                accessToken = admin.getApiKey();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if(StringUtils.isEmpty(accessToken)) {
+            accessToken = getAccessToken(companyType);
+        }
+        // 推送消息
+        RestTemplate restTemplate = new RestTemplate();
+        Map<String, Object> sendBody = new HashMap<>();
+        sendBody.put("touser", openId);
+        sendBody.put("topcolor", "#FF0000");
+        sendBody.put("data", sendMag);
+        sendBody.put("template_id", templateId);
+        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+            sendBody.put("url", "http://szwlh.sunzee.com.cn/shenze/");
+        } else {
+            sendBody.put("url", "http://sevencloud.com.cn/sc/");
+        }
+        String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
+        ResponseEntity<String> forEntity = restTemplate.postForEntity(sendUrl, sendBody, String.class);
+        JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody());
+        String messageCode = jsonObject.getString("errcode");
+        String msgId = jsonObject.getString("msgid");
+        System.out.println("messageCode : " + messageCode + ", msgId: " +msgId);
+        log.info("微信推送结果:{}","messageCode : " + messageCode + ", msgId: " +msgId);
+    }
 }

+ 134 - 0
src/main/java/com/szwl/util/WechatSendUtil.java

@@ -0,0 +1,134 @@
+package com.szwl.util;
+
+import com.alibaba.fastjson.JSONObject;
+import com.szwl.constant.ConfigConsts;
+import com.szwl.model.utils.MailUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class WechatSendUtil {
+
+
+    /**
+     * 获取小程序token
+     * @return
+     */
+//    public static String getAccessToken(String companyType) {
+//        String url = "";
+//        String accessToken = "";
+//        try {
+//            if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+//                accessToken = redisTemplate.opsForValue().get(SZ_ACCESS_TOKEN_KEY);
+//            } else {
+////                accessToken = accessTokenCache.getAccessToken(SC_ACCESS_TOKEN_KEY);
+//                accessToken = redisTemplate.opsForValue().get(SC_ACCESS_TOKEN_KEY);
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        if(StringUtils.isNotEmpty(accessToken)) {
+//            return accessToken;
+//        }
+//        if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+//            url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+//                    + ConfigConsts.SZ_WX_SUB_APP_ID + "&secret=" + ConfigConsts.SZ_WX_APP_SECRET;
+//        } else {
+//            url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+//                    + ConfigConsts.SC_WX_SUB_APP_ID + "&secret=" + ConfigConsts.SC_WX_APP_SECRET;
+//        }
+//        PrintWriter out = null;
+//        BufferedReader in = null;
+//        String line;
+//        StringBuffer stringBuffer = new StringBuffer();
+//        try {
+//            URL realUrl = new URL(url);
+//            // 打开和URL之间的连接
+//            URLConnection conn = realUrl.openConnection();
+//
+//            // 设置通用的请求属性 设置请求格式
+//            //设置返回类型
+//            conn.setRequestProperty("contentType", "text/plain");
+//            //设置请求类型
+//            conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
+//            //设置超时时间
+//            conn.setConnectTimeout(1000);
+//            conn.setReadTimeout(1000);
+//            conn.setDoOutput(true);
+//            conn.connect();
+//            // 获取URLConnection对象对应的输出流
+//            out = new PrintWriter(conn.getOutputStream());
+//            // flush输出流的缓冲
+//            out.flush();
+//            // 定义BufferedReader输入流来读取URL的响应    设置接收格式
+//            in = new BufferedReader(
+//                    new InputStreamReader(conn.getInputStream(), "UTF-8"));
+//            while ((line = in.readLine()) != null) {
+//                stringBuffer.append(line);
+//            }
+//            JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
+//            log.info("获取token:{}",jsonObject.toString());
+//            accessToken = jsonObject.getString("access_token");
+//            if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
+////                accessTokenCache.setAccessToken(SZ_ACCESS_TOKEN_KEY, accessToken);
+//                redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
+//            } else {
+////                accessTokenCache.setAccessToken(SC_ACCESS_TOKEN_KEY, accessToken);
+//                redisTemplate.opsForValue().set(SZ_ACCESS_TOKEN_KEY, accessToken, EXPIRATION_TIME, TimeUnit.SECONDS);
+//            }
+//            return accessToken;
+//
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        //使用finally块来关闭输出流、输入流
+//        finally {
+//            try {
+//                if (out != null) {
+//                    out.close();
+//                }
+//                if (in != null) {
+//                    in.close();
+//                }
+//            } catch (IOException ex) {
+//                ex.printStackTrace();
+//            }
+//        }
+//        return null;
+//    }
+
+    public static void sentEmail(String email,String name) {
+        String subject = "Error message from Magic Candy Machine";
+        StringBuffer contnet = new StringBuffer();
+        String str1="Dear customer<br>" +
+                "<br>" +
+                "This is an automatic-sent mail to inform you that there is an error occurred on one of your Magic Candy machines, please kindly check the detail as below.<br>" +
+                "<br>" +
+                " Machine name:";
+        String str2="<br>" +" Chinse Time&Date:";
+        String str3="<br>"+" Error Message:";
+        String scontent="Abnormal shutdown/The network is disconnected,";
+        String str4= "<br>" +" <br>You don't have to reply this mail . What you need to do is to follow the instructions on the touch screen to clear the error and recover the machine. If there is any question or more information you need . Please do not be hesitated to contact your distributor.<br>" +
+                "<br>" +
+                " Thank you for choosing our machine!<br>" +
+                "<br>" +
+                "<br>" +
+                "Best Regards.<br>" +
+                "Magic Candy Service Team";
+        contnet.append(str1).append(name).append(str2).append(new Date()).append(str3).append(scontent).append(str4);
+        MailUtil mailUtil = new MailUtil();
+        mailUtil.send(email, subject, contnet.toString());
+        System.out.println("邮件发送成功");
+    }
+}

+ 51 - 0
src/main/java/com/szwl/util/geoCoderUtil.java

@@ -0,0 +1,51 @@
+package com.szwl.util;
+
+import cn.hutool.http.HttpUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.net.URLEncoder;
+
+public class geoCoderUtil {
+    // 地理位置逆编码
+    private static final String TD_KEY = "26bac63d19fac57c16bc7759455431d8";
+
+    private static final String TD_URL = "http://api.tianditu.gov.cn/geocoder";
+    // 请求:http://api.tianditu.gov.cn/geocoder?postStr={'lon':116.37304,'lat':39.92594,'ver':1}&type=geocode&tk=您的密钥
+
+
+
+    public static String getLocByLonLatVer(String lon, String lat) throws Exception {
+        String ver = "1"; // 版本号
+        String reqUrl = TD_URL + "?postStr={'lon':" + lon + ",'lat':" + lat + ",'ver':" + ver + "}&type=geocode&tk=" + URLEncoder.encode(TD_KEY, "UTF-8");
+        String s = HttpUtil.get(reqUrl);
+        return getNotionAddr(s);
+
+    }
+
+    public static String getNotionAddr(String result) {
+        ObjectMapper mapper = new ObjectMapper();
+
+        try {
+            JsonNode node = mapper.readTree(result);
+
+            String nation = node.at("/result/addressComponent/nation").asText();
+            String address = node.at("/result/addressComponent/address").asText();
+
+//            System.out.println("Nation + Address:" + nation + address);
+            return nation + address;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+//    public static void main(String[] args) throws Exception {
+//        String lon = "127.0013";
+//        String lat = "37.5015";
+//
+//        String response = getLocByLonLatVer(lon, lat);
+//        System.out.println(response);
+//    }
+}
+

+ 1 - 1
src/test/java/com/szwl/AutoGeneratorTests.java

@@ -47,7 +47,7 @@ class AutoGeneratorTests {
 		strategyConfig
 //				.setCapitalMode(true)//设置全局大写命名
 				.setInclude(new String[]{
-						"t_hot_update"
+						"t_alarm_clean"
 				})//只会生成该表
 				.setEntityLombokModel(true)//实体类生成之后自动添加lombok注解
 				.setNaming(NamingStrategy.underline_to_camel)//数据库表映射到实体的命名策略

+ 51 - 0
src/test/java/com/szwl/controller/TestController.java

@@ -0,0 +1,51 @@
+package com.szwl.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+import java.util.StringTokenizer;
+import org.junit.Test;
+
+@Slf4j
+@Api(value = "/tTest", tags = {"测试"})
+@RestController
+@RequestMapping("/tTest")
+public class TestController {
+
+    @Test
+    @ApiOperation(value = "测试")
+    @PostMapping("/testService")
+    public void testService(){
+        String country = "美国";
+
+        String addr = "日本冲绳札幌市二丁目";
+
+        boolean containsUserInput = isAddressInCountryList(addr, country);
+        if (!containsUserInput) {
+            System.out.println("不包含");
+        }
+        System.out.println("通过,包含");
+    }
+
+
+    public static boolean isAddressInCountryList(String addr, String country) {
+        // 使用StringTokenizer分割国家字符串
+        StringTokenizer tokenizer = new StringTokenizer(country, "、");
+
+        // 循环遍历国家列表
+        while (tokenizer.hasMoreTokens()) {
+            String singleCountry = tokenizer.nextToken();
+            // 如果地址包含当前国家,则返回true
+            if (addr.contains(singleCountry)) {
+                return true;
+            }
+        }
+        // 如果没有找到匹配的国家,则返回false
+        return false;
+    }
+}

+ 71 - 0
src/test/java/com/szwl/service/impl/TEquipmentServiceImplTest.java

@@ -0,0 +1,71 @@
+package com.szwl.service.impl;
+
+import com.szwl.model.utils.MailUtil;
+import com.szwl.model.utils.YunPianSms;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.IOException;
+
+
+class TEquipmentServiceImplTest {
+
+    public static void main(String[] args) {
+        String ifForeign = "0";
+        String phone = "18620242721";
+        String email = "446678759@qq.com";
+        String appid = "07784f5fedb508046c841b391005b7de";
+        String deviceId = "c12345678";
+
+        doTest( ifForeign,  phone,  email,  appid,  deviceId);
+    }
+    public static void doTest(String ifForeign, String phone, String email, String appid, String deviceId) {
+        switch (ifForeign) {
+            case "0": { // 国内发短信
+                if (StringUtils.isEmpty(phone)) {
+                    return;
+                }
+                try {
+                    String sms = YunPianSms.sendSms(appid, getInformText(deviceId), phone);
+                    System.out.println("短信已发送:" + sms);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+                break;
+            }
+            case "1": { // 海外发邮箱
+                if (StringUtils.isEmpty(email)) {
+                    return;
+                }
+                String subject = "Reset the price of the flowers"; // 邮件标题
+                String content = getInformContent(deviceId); // 邮件正文
+                new MailUtil().send(email, subject, content);
+                break;
+            }
+            default:
+                System.out.println("无效的ifForeign");
+                break;
+        }
+    }
+
+    private static String getInformContent(String deviceId) {
+        String content;
+        String str = "Dear customer:<br>" +
+                "<br>" +
+                "Your machine number is <" + deviceId + "> cotton candy machine, the number of flowers has been pushed, please reset the price of the flowers!" +
+                "<br>" +
+                "<br>" +
+                "Best Regards.<br>" +
+                "Sunzee Intelligent";
+        content = String.format(str);
+        return content;
+    }
+
+    private static String getInformText(String deviceId) {
+        String sms = "";
+        if(StringUtils.isNotEmpty(deviceId)){
+            sms = "【申泽智能】您好,您名下设备编号为" + deviceId + "的机器,花型数量已推送,请重新设置价格!";
+        }
+        return sms;
+    }
+
+}