Browse Source

Merge remote-tracking branch 'origin/master'

lin 3 years ago
parent
commit
eab4b1de6f

+ 1 - 1
src/main/java/com/zoniot/ccrc/dao/MeterReadRecordMapper.java

@@ -30,5 +30,5 @@ public interface MeterReadRecordMapper {
             @Param("date")Integer date);
     int batchInsert(@Param("list") List<MeterReadRecord> list);
 
-    MeterReadRecord findRecordByReadDayAndDeviceId(Long deviceId, Integer readDate);
+    MeterReadRecord findRecordByReadDayAndDeviceId( @Param("deviceId")Long deviceId,  @Param("readDate")Integer readDate);
 }

+ 2 - 0
src/main/java/com/zoniot/ccrc/dao/MeterRecordMapper.java

@@ -108,5 +108,7 @@ public interface MeterRecordMapper {
     void updateDeviceStatus();
 
 
+    List<Long> selectWaitSyncDeviceId();
 
+    void updateId(@Param("id")Long id, @Param("newId")long newId);
 }

+ 14 - 7
src/main/java/com/zoniot/ccrc/scheduled/SyncData.java

@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -59,24 +60,28 @@ public class SyncData {
     private String apiUrl;
     @Resource
     private CommunityMapper communityMapper;
-
+    @Scheduled(cron = "0 0 20 * * ?")
     public void synchronousData(){
-       syncCell();
+
+        syncCell();
         log.info("同步小区完毕");
         syncDevice();
         log.info("同步设备完毕");
         syncReading();
         log.info("同步设备读数完毕");
-       // synchronizeLatitudeAndLongitude();
+        synchronizeLatitudeAndLongitude();
         log.info("小区地理反编码完毕");
     }
     private void syncDevice(){
 
-        meterRecordMapper.syncDevice(siteId,snowflakeIdWorker.nextId());
-        //meterRecordMapper.deleteDevice();
+        meterRecordMapper.syncDevice(siteId,1);
+
+
+      // meterRecordMapper.deleteDevice();
     }
     private void syncCell(){
         meterRecordMapper.syncCell(siteId,provinceId,cityId,regionId);
+
     }
     private void syncReading(){
         int size=1000;
@@ -92,11 +97,12 @@ public class SyncData {
             offset=offset+size;
             generateReadingRecords(waterMeterList,readDay);
         }
-        meterRecordMapper.updateDeviceStatus();
+       meterRecordMapper.updateDeviceStatus();
 
 
     }
     private String[] getInfoFromGaode(String name,String city){
+        name=name.trim();
         String request = apiUrl+"?key="+apikey+"&address="+name+"&city="+city;
         String[] tts=null;
         try {
@@ -121,7 +127,7 @@ public class SyncData {
       return tts;
     }
     private void synchronizeLatitudeAndLongitude(){
-      //  meterRecordMapper.deleteCell();
+       meterRecordMapper.deleteCell();
         List<Community>communitys=meterRecordMapper.getCommunityIds();
         communitys.forEach(community -> {
             String[] infoFromGaode = getInfoFromGaode(community.getName(),community.getAddress());
@@ -177,6 +183,7 @@ public class SyncData {
     public void updateReadData(WaterMeter waterMeter){
         if(waterMeter.getDeviceTypeId()==1){
             MeterReadRecord meterReadRecord=new MeterReadRecord();
+            meterReadRecord.setDeviceId(waterMeter.getDeviceId());
             setMeterRead(waterMeter.getRegistNo(),meterReadRecord);
             DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
             LocalDateTime endDateTime = LocalDateTime.now().plusDays(-1);

+ 1 - 1
src/main/java/com/zoniot/ccrc/security/WebSecurityConfig.java

@@ -98,7 +98,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                 .and().authorizeRequests()
                 .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
-                .anyRequest().authenticated()
+               // .anyRequest().authenticated()
                 .and()
                 .formLogin()
                 .successHandler(authenticationSuccessHandler)//登陆成功处理

+ 5 - 5
src/main/resources/application-dev.properties

@@ -46,8 +46,8 @@ spring.redis.port=26379
 spring.redis.password=zoniot
 #spring.redis.port=6379
 #spring.redis.password=100Zone@123
-spring.redis.database=3
-
+spring.redis.database=1
+init.data.cache = 0
 spring.redis.timeout=10000ms
 spring.redis.jedis.pool.max-active=8
 spring.redis.jedis.pool.max-idle=8
@@ -101,9 +101,9 @@ wechat.oa.appid=wx6b2ce547cd593413
 wechat.mp.appid=wx27f831675081e293
 wechat.mp.app-secret=a01d7f75f15e1a6b7fa28a317f97ef1b
 site_id=1
-province_id=1
-city_id=1
-region_id=1
+province_id=120000
+city_id=120100
+region_id=120112
 geomap.apikey=bb218fd3700b37dd1e02872365cab4d5
 geomap.api.url=https://restapi.amap.com/v3/geocode/geo
 

+ 16 - 6
src/main/resources/application-prd.properties

@@ -10,8 +10,8 @@ spring.thymeleaf.prefix=classpath:/templates/
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 #使用druid数据源
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
-spring.datasource.url=jdbc:mysql://20.0.0.108:3306/ccrc?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false
-spring.datasource.username=ccrc
+spring.datasource.url=jdbc:mysql://192.168.21.109:3306/ccrc?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false
+spring.datasource.username=root
 spring.datasource.password=100zone@zoniot
 spring.datasource.druid.initial-size=5
 spring.datasource.druid.min-idle=5
@@ -40,14 +40,18 @@ spring.jackson.time-zone=GMT+8
 #spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss
 
 # redis
+spring.redis.host=127.0.0.1
+spring.redis.port=6379
+spring.redis.password=zoniot
+#spring.redis.port=6379
+#spring.redis.password=100Zone@123
+spring.redis.database=1
+init.data.cache = 0
 spring.redis.timeout=10000ms
 spring.redis.jedis.pool.max-active=8
 spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-wait=-1ms
 spring.redis.jedis.pool.min-idle=2
-spring.redis.sentinel.master=mymaster
-# comma-separated list of host:port pairs  哨兵的配置列表
-spring.redis.sentinel.nodes=10.0.0.71:26379,10.0.0.72:26379,10.0.0.73:26379
 
 jwt.secret=smartCity123
 jwt.expiration=36000
@@ -98,4 +102,10 @@ spring.data.mongodb.database=meter-reading-database
 wechat.oa.appid=wx6b2ce547cd593413
 #小程序水查查服务
 wechat.mp.appid=wx6e9d9023b7b89797
-wechat.mp.app-secret=cde6834d701114722bdad092526572cf
+wechat.mp.app-secret=cde6834d701114722bdad092526572cf
+site_id=1
+province_id=120000
+city_id=120100
+region_id=120112
+geomap.apikey=bb218fd3700b37dd1e02872365cab4d5
+geomap.api.url=https://restapi.amap.com/v3/geocode/geo

+ 3 - 3
src/main/resources/application-sit.properties

@@ -102,9 +102,9 @@ wechat.oa.appid=wx6b2ce547cd593413
 wechat.mp.appid=wx27f831675081e293
 wechat.mp.app-secret=a01d7f75f15e1a6b7fa28a317f97ef1b
 site_id=1
-province_id=1
-city_id=1
-region_id=1
+province_id=120000
+city_id=120100
+region_id=120112
 geomap.apikey=bb218fd3700b37dd1e02872365cab4d5
 geomap.api.url=https://restapi.amap.com/v3/geocode/geo
 

+ 11 - 5
src/main/resources/mapper/MeterRecordMapper.xml

@@ -137,8 +137,8 @@
         select * from crcc_mid_meter_record where regist_no=#{registNo}
     </select>
     <select id="syncCell">
-        insert into sc_community(site_id,name,province,city,region,uniq_id,status,date_create)
-        select #{siteId},name,#{provinceId},#{cityId},#{regionId},code,1,now() from crcc_mid_community
+        insert into sc_community(code,site_id,name,province,city,region,uniq_id,status,date_create)
+        select code, #{siteId},name,#{provinceId},#{cityId},#{regionId},code,1,now() from crcc_mid_community
         ON DUPLICATE KEY UPDATE name=VALUES(name),date_update=now()
     </select>
     <select id="getCommunityIds" resultType="com.zoniot.ccrc.entity.Community">
@@ -150,23 +150,29 @@
                device_type_id,site_id,sys_id,meter_no,file_no meterFileNo,regist_no
         from sc_device where status=1 and regist_no is not null limit #{offset},#{size}
     </select>
+    <select id="selectWaitSyncDeviceId" resultType="java.lang.Long">
+        select id from sc_device where sync_flag=0;
+    </select>
     <update id="updateDeviceStatus">
         update sc_device a,crcc_mid_meter_record b set a.valve_status =b.valve_status
                        ,a.device_status=b.meter_status,a.last_receive_time=b.reading_time,
             a.meter_reading=b.meter_reading,a.meter_status_info=b.meter_status_info
           where a.regist_no=b.regist_no
     </update>
+    <update id="updateId">
+        update sc_device set sync_flag=1,id=#{newId} where id=#{id};
+    </update>
     <insert id="syncDevice">
-        INSERT INTO sc_device (id,regist_no,device_no,file_no,site_id,sys_id
+        INSERT INTO sc_device (regist_no,device_no,file_no,site_id,sys_id
                               ,device_type_id,manufacturer_id,community_id,loc_desc,status,
                                date_create,date_update,client_user_mobile,client_user_name,client_user_no)
-        select #{deviceId},regist_no,meter_no,regist_no,#{siteId}, CASE meter_type WHEN 1 THEN  40 ELSE
+        select regist_no,meter_no,regist_no,#{siteId}, CASE meter_type WHEN 1 THEN  40 ELSE
             58 END sysId,meter_type,1,b.id,concat(a.address,a.location),1,now(),now(),client_user_mobile,
                client_user_name,client_user_no
 
         from crcc_mid_meter a join sc_community b
                                    on a.community_code=b.uniq_id
-        ON DUPLICATE KEY UPDATE device_no=VALUES(meter_no),
+        ON DUPLICATE KEY UPDATE device_no=a.meter_no,
                                 file_no=VALUES(regist_no),community_id=b.id,
                                 loc_desc=concat(a.address,a.location),date_update=now(),
                                 client_user_mobile=VALUES(client_user_mobile),