Browse Source

Merge remote-tracking branch 'origin/20200908' into 20200908

hym 4 years ago
parent
commit
29760a7987

+ 50 - 2
meter-reading-job/pom.xml

@@ -13,6 +13,12 @@
     <artifactId>meter-reading-job</artifactId>
     <version>1.0</version>
     <description>抄表作业子模块</description>
+    <properties>
+        <maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>com.huaxu.zoniot</groupId>
@@ -53,11 +59,53 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <!-- 1、设置jar的入口类 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix>lib/</classpathPrefix>
+                            <mainClass>com.huaxu.zoniot.MeterReadingJobApplication</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+
+
+            <!--2、把附属的jar打到jar内部的lib目录中 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+
+            <!-- 3、打包过程忽略Junit测试 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                    <fork>true</fork>
-                    <addResources>true</addResources>
+                    <skip>true</skip>
                 </configuration>
             </plugin>
+
         </plugins>
     </build>
 </project>

+ 23 - 0
meter-reading-job/src/main/java/com/huaxu/zoniot/dao/WaterMeterErrorDaysMapper.java

@@ -0,0 +1,23 @@
+package com.huaxu.zoniot.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+
+/**
+ * <p>水表连续故障天数</p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/7 15:53
+ * @Version 1.0
+ */
+@Mapper
+public interface WaterMeterErrorDaysMapper {
+    /**
+     * 更新连续故障天数
+     * @param errorDay
+     * @return
+     */
+    int updateErrorDays(@Param("errorDay") Integer errorDay , @Param("date")Date date);
+}

+ 32 - 0
meter-reading-job/src/main/java/com/huaxu/zoniot/job/WaterMeterErrorDaysJob.java

@@ -0,0 +1,32 @@
+package com.huaxu.zoniot.job;
+
+import com.huaxu.zoniot.service.WaterMeterErrorDaysService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * <p></p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/7 17:38
+ * @Version 1.0
+ */
+@Slf4j
+@Component
+public class WaterMeterErrorDaysJob {
+    @Autowired
+    WaterMeterErrorDaysService  waterMeterErrorDaysService ;
+
+
+    @XxlJob("clearWaterMeterErrorDaysJob")
+    public ReturnT<String> clearWaterMeterErrorDaysJobHandler(String param) throws Exception {
+        XxlJobLogger.log("XXL-JOB, Clear Water Meter Error Days Job .Param = {}",param);
+        int result = waterMeterErrorDaysService.clearErrorDays();
+        XxlJobLogger.log("XXL-JOB, Clear Water Meter Error Days Job .Total = {}", result);
+        return ReturnT.SUCCESS;
+    }
+}

+ 12 - 0
meter-reading-job/src/main/java/com/huaxu/zoniot/service/WaterMeterErrorDaysService.java

@@ -0,0 +1,12 @@
+package com.huaxu.zoniot.service;
+
+/**
+ * <p>水表故障天数</p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/7 16:00
+ * @Version 1.0
+ */
+public interface WaterMeterErrorDaysService {
+    int clearErrorDays();
+}

+ 28 - 0
meter-reading-job/src/main/java/com/huaxu/zoniot/service/impl/WaterMeterErrorDaysServiceImpl.java

@@ -0,0 +1,28 @@
+package com.huaxu.zoniot.service.impl;
+
+import com.huaxu.zoniot.dao.WaterMeterErrorDaysMapper;
+import com.huaxu.zoniot.service.WaterMeterErrorDaysService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * <p></p>
+ *
+ * @Author wilian.peng
+ * @Date 2021/1/7 16:01
+ * @Version 1.0
+ */
+@Slf4j
+@Service
+public class WaterMeterErrorDaysServiceImpl implements WaterMeterErrorDaysService {
+    @Autowired
+    WaterMeterErrorDaysMapper  waterMeterErrorDaysMapper ;
+
+    @Override
+    public int clearErrorDays() {
+        return waterMeterErrorDaysMapper.updateErrorDays(0,new Date());
+    }
+}

+ 12 - 0
meter-reading-job/src/main/resources/mapper/WaterMeterErrorDaysMapper.xml

@@ -0,0 +1,12 @@
+<?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.huaxu.zoniot.dao.WaterMeterErrorDaysMapper">
+    <update id="updateErrorDays" >
+        UPDATE
+            sc_water_meter_error_days set days = #{errorDay},start_date = null,end_date = null
+        WHERE
+
+            end_date <![CDATA[ < ]]>DATE_FORMAT(date_add(#{date}, interval -1 day), '%Y%m%d' )
+        and status = 1
+    </update>
+</mapper>

+ 1 - 1
meter-reading-job/src/main/resources/script/sql/water_meter_error_day.sql

@@ -1,2 +1,2 @@
 -- 每天更新连续异常天数
-UPDATE sc_water_meter_error_days set days = 0,start_date = null,end_date = null WHERE end_date < DATE_FORMAT(date_add(:date, interval -1 day), '%Y%m%d' ) and status = 1
+UPDATE sc_water_meter_error_days set days = 0,start_date = null,end_date = null WHERE end_date < DATE_FORMAT(date_add(#{date}, interval -1 day), '%Y%m%d' ) and status = 1

+ 2 - 2
smart-city-intf/src/main/java/com/zcxk/smartcity/data/access/dto/DeviceData.java

@@ -15,8 +15,8 @@ import java.util.Map;
  * 
  * @Description  
  * <p>设备数据表,按照设备ID进行分片</p>
- * sh.enableSharding("iot-water-database")
- * sh.shardCollection("iot-water-database.sc_device_data",{"receiveDate":1,"deviceId":1});
+ * sh.enableSharding("meter-reading-database")
+ * sh.shardCollection("meter-reading-database.sc_device_data",{"receiveDate":1,"deviceId":1});
  * @author wilian.peng
  * @date 2019年11月12日 下午10:05:10
  */

+ 1 - 1
smart-city-intf/src/main/resources/application-sit-node0.properties

@@ -76,5 +76,5 @@ com.zcxk.rabbitmq.water.meter.queue=water_meter_queue
 com.zcxk.rabbitmq.command.status.queue=command_status_queue
 com.zcxk.rabbitmq.meter.data.exchange=meter-data-exchange
 ######################################################MongoDB配置#####################################################
-spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
 logging.level.org.springframework.data.mongodb.core=DEBUG

+ 1 - 1
smart-city-intf/src/main/resources/application-sit-node1.properties

@@ -76,5 +76,5 @@ com.zcxk.rabbitmq.water.meter.queue=water_meter_queue
 com.zcxk.rabbitmq.command.status.queue=command_status_queue
 com.zcxk.rabbitmq.meter.data.exchange=meter-data-exchange
 ######################################################MongoDB配置#####################################################
-spring.data.mongodb.uri=mongodb://114.135.61.188:17017/iot-water-database
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
 logging.level.org.springframework.data.mongodb.core=DEBUG