Redeem il y a 3 jours
Parent
commit
75a70996b8
28 fichiers modifiés avec 1130 ajouts et 288 suppressions
  1. 5 5
      pom.xml
  2. 12 6
      src/main/java/com/steerinfo/SysManageApplication.java
  3. 21 0
      src/main/java/com/steerinfo/abnormalHandler/controller/StatusSyncController.java
  4. 22 0
      src/main/java/com/steerinfo/abnormalHandler/mapper/StatusSyncMapper.java
  5. 19 0
      src/main/java/com/steerinfo/abnormalHandler/model/AbnormalPrediction.java
  6. 30 0
      src/main/java/com/steerinfo/abnormalHandler/scheduler/StatusSyncScheduler.java
  7. 231 0
      src/main/java/com/steerinfo/abnormalHandler/service/StatusSyncService.java
  8. 176 176
      src/main/java/com/steerinfo/baseinfo/appverificationcode/service/impl/AppVerificationCodeServiceImpl.java
  9. 18 17
      src/main/java/com/steerinfo/baseinfo/appverificationcode/service/impl/InboundMessageCallbackTestImpl.java
  10. 2 1
      src/main/java/com/steerinfo/filter/SecurityFilter.java
  11. 22 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractual/controller/MeterWorkCarActualController.java
  12. 8 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractual/mapper/MeterWorkCarActualMapper.java
  13. 17 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractual/mapper/MeterWorkCarActualMapper.xml
  14. 3 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractual/service/IMeterWorkCarActualService.java
  15. 14 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractual/service/impl/MeterWorkCarActualServiceImpl.java
  16. 10 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/controller/MeterWorkCarActualFirstController.java
  17. 40 0
      src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/mapper/MeterWorkCarActualFirstMapper.java
  18. 156 4
      src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/mapper/MeterWorkCarActualFirstMapper.xml
  19. 116 49
      src/main/java/com/steerinfo/meterwork/meterworkdatacount/mapper/MeterWorkDataCountMapper.xml
  20. 18 0
      src/main/java/com/steerinfo/meterwork/meterworkdatacount/model/TruckHisTareComparison.java
  21. 2 1
      src/main/java/com/steerinfo/meterwork/meterworkparammap/service/impl/MeterWorkParamMapService.java
  22. 1 1
      src/main/java/com/steerinfo/meterwork/meterworkprewgttype/service/impl/MeterWorkPreWgttypeServiceImpl.java
  23. 16 0
      src/main/java/com/steerinfo/meterwork/meterworkrailwayactfirst/mapper/MeterWorkRailwayActFirstMapper.java
  24. 128 1
      src/main/java/com/steerinfo/meterwork/meterworkrailwayactfirst/mapper/MeterWorkRailwayActFirstMapper.xml
  25. 12 3
      src/main/resources/application-prod.properties
  26. 9 6
      src/main/resources/application.properties
  27. 21 18
      src/main/resources/bootstrap.yml
  28. 1 0
      src/main/resources/log4j.properties

+ 5 - 5
pom.xml

@@ -218,11 +218,11 @@
             <artifactId>javacv-platform</artifactId>
             <version>1.5.4</version>
         </dependency>
-        <dependency>
-            <groupId>com.wellbole</groupId>
-            <artifactId>smsengine-client</artifactId>
-            <version>3.8.0</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.wellbole</groupId>-->
+<!--            <artifactId>smsengine-client</artifactId>-->
+<!--            <version>3.8.0</version>-->
+<!--        </dependency>-->
     </dependencies>
 
     <repositories>

+ 12 - 6
src/main/java/com/steerinfo/SysManageApplication.java

@@ -20,6 +20,7 @@ import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.context.request.RequestContextListener;
@@ -38,6 +39,7 @@ import java.util.List;
 @EnableCaching
 @SpringBootApplication
 @EnableSwagger2
+@EnableScheduling   // ← 必须有
 @EnableFeignClients("com.steerinfo.feign")
 @EnableCircuitBreaker
 @EnableHystrix
@@ -46,15 +48,19 @@ import java.util.List;
 public class SysManageApplication implements WebMvcConfigurer {
 
     public static void main(String[] args) {
-        long startTime = System.currentTimeMillis();
+        try {
+            long startTime = System.currentTimeMillis();
 
-        SpringApplication app = new SpringApplication(SysManageApplication.class);
+            SpringApplication app = new SpringApplication(SysManageApplication.class);
 //		app.addListeners(new ContextRefreshedListener());
-        app.run(args);
+            app.run(args);
 
-        long endTime = System.currentTimeMillis();
-        float excTime = (float) (endTime - startTime) / 1000;
-        //system.out.println("====================================>执行时间:" + excTime + "s");
+            long endTime = System.currentTimeMillis();
+            float excTime = (float) (endTime - startTime) / 1000;
+            //system.out.println("====================================>执行时间:" + excTime + "s");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
     }
 

+ 21 - 0
src/main/java/com/steerinfo/abnormalHandler/controller/StatusSyncController.java

@@ -0,0 +1,21 @@
+package com.steerinfo.abnormalHandler.controller;
+
+import com.steerinfo.abnormalHandler.service.StatusSyncService;
+import com.steerinfo.framework.controller.BaseRESTfulController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/${api.version}/statusSync")
+public class StatusSyncController extends BaseRESTfulController {
+
+    @Autowired
+    StatusSyncService statusSyncService;
+
+    @PostMapping("/syncStatus")
+    public void syncStatus() {
+        statusSyncService.doSync();
+    }
+}

+ 22 - 0
src/main/java/com/steerinfo/abnormalHandler/mapper/StatusSyncMapper.java

@@ -0,0 +1,22 @@
+package com.steerinfo.abnormalHandler.mapper;
+
+import com.steerinfo.framework.mapper.IBaseMapper;
+import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualFirst;
+import com.steerinfo.pretrack.pretrackscale.model.PreTrackScale;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface StatusSyncMapper extends IBaseMapper<PreTrackScale, String> {
+    // 规则1:洁净表正常,一次表有效
+    List<MeterWorkCarActualFirst> selectRule1PredictionNos();
+
+    // 规则2:洁净表正常,预报表正使用
+    List<PreTrackScale> selectRule2PredictionNos();
+
+    // 规则3:一次表存在,洁净表不存在,预报表未使用
+    List<PreTrackScale> selectRule3PredictionNos();
+    // 规则4:一次表不存在,洁净表不存在,预报表已使用/正使用
+    List<PreTrackScale> selectRule4PredictionNos();
+}

+ 19 - 0
src/main/java/com/steerinfo/abnormalHandler/model/AbnormalPrediction.java

@@ -0,0 +1,19 @@
+package com.steerinfo.abnormalHandler.model;
+
+import lombok.Data;
+
+@Data
+public class AbnormalPrediction {
+    /**
+     * 预报号
+     */
+    private String predictionNo;
+    /**
+     * 命中的规则编号:1, 2, 3, 4
+     */
+    private String ruleCode;
+    /**
+     * 当前状态值(用于日志输出,便于排查)
+     */
+    private String currentFlag;
+}

+ 30 - 0
src/main/java/com/steerinfo/abnormalHandler/scheduler/StatusSyncScheduler.java

@@ -0,0 +1,30 @@
+package com.steerinfo.abnormalHandler.scheduler;
+
+import com.steerinfo.abnormalHandler.service.StatusSyncService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * 状态同步定时调度器
+ * 每分钟执行一次,通过配置开关控制是否启用
+ */
+@Component
+@Slf4j
+@ConditionalOnProperty(name = "meter.sync.enabled", havingValue = "true", matchIfMissing = false)
+public class StatusSyncScheduler {
+
+    @Autowired
+    private StatusSyncService statusSyncService;
+
+    /**
+     * 每分钟执行一次状态同步
+     */
+    @Scheduled(cron = "0 */3 * * * ?")
+    public void scheduledSync() {
+        log.info("========== 开始执行状态同步定时任务 ==========");
+        statusSyncService.doSync();
+    }
+}

+ 231 - 0
src/main/java/com/steerinfo/abnormalHandler/service/StatusSyncService.java

@@ -0,0 +1,231 @@
+package com.steerinfo.abnormalHandler.service;
+
+import com.steerinfo.abnormalHandler.mapper.StatusSyncMapper;
+import com.steerinfo.meterwork.meterworkcaractualfirst.mapper.MeterWorkCarActualFirstMapper;
+import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualFirst;
+import com.steerinfo.meterwork.meterworkrailwayactfirst.mapper.MeterWorkRailwayActFirstMapper;
+import com.steerinfo.meterwork.meterworkrailwayactfirst.model.MeterWorkRailwayActFirst;
+import com.steerinfo.pretrack.prerailwayscale.mapper.PreRailwayScaleMapper;
+import com.steerinfo.pretrack.prerailwayscale.model.PreRailwayScale;
+import com.steerinfo.pretrack.pretrackscale.mapper.PreTrackScaleMapper;
+import com.steerinfo.pretrack.pretrackscale.model.PreTrackScale;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Service
+@Slf4j
+public class StatusSyncService {
+
+    @Autowired
+    private StatusSyncMapper mapper;
+
+    @Autowired
+    private MeterWorkCarActualFirstMapper meterWorkCarActualFirstMapper;
+
+    @Autowired
+    private PreTrackScaleMapper preTrackScaleMapper;
+
+    @Autowired
+    private MeterWorkRailwayActFirstMapper meterWorkRailwayActFirstMapper;
+
+    @Autowired
+    private PreRailwayScaleMapper preRailwayScaleMapper;
+
+    public void doSync() {
+        long startTime = System.currentTimeMillis();
+        log.info("========== 开始执行状态同步 ==========");
+
+        // 1. 汽运分别查询四条规则的数据
+        // 首先是一次表状态不对,已经洁净了,但是一次表还是有效,返回的是一次实绩编号
+        List<String> carRule1List  = meterWorkCarActualFirstMapper.selectRule1PredictionNos();
+        // 其次是预报表状态不对,已经结束使用了,但是预报表还是正使用,返回的是预报编号
+        List<String> carRule2List  = meterWorkCarActualFirstMapper.selectRule2PredictionNos();
+        // 再次是预报表状态不对,已经正使用了,但是预报表还是未使用,返回的是预报编号
+        List<String> carRule3List  = meterWorkCarActualFirstMapper.selectRule3PredictionNos();
+        // 最后是预报表状态不对,已经未使用了,但是预报表还是正使用或者已使用,返回的是预报编号
+//        List<String> carRule4List  = meterWorkCarActualFirstMapper.selectRule4PredictionNos();
+        // 最后后是一次表状态不对,应该是 有效,但是一次表还是已结净,返回的是一次实绩编号
+//        List<String> carRule5List  = meterWorkCarActualFirstMapper.selectRule5PredictionNos();
+
+        // 1. 火运分别查询四条规则的数据
+        // 首先是一次表状态不对,已经洁净了,但是一次表还是有效,返回的是一次实绩编号
+        List<String> trainRule1List  = meterWorkRailwayActFirstMapper.selectRule1PredictionNos();
+        // 其次是预报表状态不对,已经结束使用了,但是预报表还是正使用,返回的是预报编号
+        List<String> trainRule2List  = meterWorkRailwayActFirstMapper.selectRule2PredictionNos();
+        // 再次是预报表状态不对,已经正使用了,但是预报表还是未使用,返回的是预报编号
+        List<String> trainRule3List  = meterWorkRailwayActFirstMapper.selectRule3PredictionNos();
+        // 最后是预报表状态不对,已经未使用了,但是预报表还是正使用或者已使用,返回的是预报编号
+//        List<String> trainRule4List  = meterWorkRailwayActFirstMapper.selectRule4PredictionNos();
+
+
+        // 2. 日志记录每条规则查到多少条
+        // ============================================================
+        log.info("【汽运】规则1(一次表 有效→已结净) 查到 {} 条", carRule1List.size());
+        log.info("【汽运】规则2(预报表 正使用→已使用) 查到 {} 条", carRule2List.size());
+        log.info("【汽运】规则3(预报表 未使用→正使用) 查到 {} 条", carRule3List.size());
+//        log.info("【汽运】规则4(预报表 已使用/正使用→未使用) 查到 {} 条", carRule4List.size());
+//        log.info("【汽运】规则5(一次表 已结净→有效回退) 查到 {} 条", carRule5List.size());
+
+        log.info("【火运】规则1(一次表 有效→已结净) 查到 {} 条", trainRule1List.size());
+        log.info("【火运】规则2(预报表 正使用→已使用) 查到 {} 条", trainRule2List.size());
+        log.info("【火运】规则3(预报表 未使用→正使用) 查到 {} 条", trainRule3List.size());
+//        log.info("【火运】规则4(预报表 已使用/正使用→未使用) 查到 {} 条", trainRule4List.size());
+
+        // ============================================================
+        // 4. 执行更新(每条规则独立处理,互不影响)
+        //    - 每个更新方法内部自带 WHERE VALUE_FLAG = '旧值' 校验
+        //    - 若状态已被人工修改,影响行数=0,自动跳过
+        // ============================================================
+        int totalSuccess = 0;
+        int totalFail = 0;
+        // ---- 汽运规则1:一次表 '有效(1)' → '已结净(2)' ----
+        if (!carRule1List.isEmpty()) {
+            int[] result = executeUpdates(carRule1List,
+                    id -> meterWorkCarActualFirstMapper.updateFirstByRule1(id),
+                    "汽运规则1", "一次表 有效→已结净");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【汽运规则1】无待处理数据,跳过");
+        }
+
+        // ---- 汽运规则2:预报表 '正使用(1)' → '已使用(2)' ----
+        if (!carRule2List.isEmpty()) {
+            int[] result = executeUpdates(carRule2List,
+                    id -> meterWorkCarActualFirstMapper.updatePredictionByRule2(id),
+                    "汽运规则2", "预报表 正使用→已使用");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【汽运规则2】无待处理数据,跳过");
+        }
+
+        // ---- 汽运规则3:预报表 '未使用(4)' → '正使用(1)' ----
+        if (!carRule3List.isEmpty()) {
+            int[] result = executeUpdates(carRule3List,
+                    id -> meterWorkCarActualFirstMapper.updatePredictionByRule3(id),
+                    "汽运规则3", "预报表 未使用→正使用");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【汽运规则3】无待处理数据,跳过");
+        }
+
+//        // ---- 汽运规则4:预报表 '正使用(1)/已使用(2)' → '未使用(4)' ----
+//        if (!carRule4List.isEmpty()) {
+//            int[] result = executeUpdates(carRule4List,
+//                    id -> meterWorkCarActualFirstMapper.updatePredictionByRule4(id),
+//                    "汽运规则4", "预报表 已使用/正使用→未使用");
+//            totalSuccess += result[0];
+//            totalFail += result[1];
+//        } else {
+//            log.info("【汽运规则4】无待处理数据,跳过");
+//        }
+
+        // ---- 汽运规则5:一次表 '已结净(2)' → '有效(1)'(回退) ----
+//        if (!carRule5List.isEmpty()) {
+//            int[] result = executeUpdates(carRule5List,
+//                    id -> meterWorkCarActualFirstMapper.updateFirstByRule5(id),
+//                    "汽运规则5", "一次表 已结净→有效(回退)");
+//            totalSuccess += result[0];
+//            totalFail += result[1];
+//        } else {
+//            log.info("【汽运规则5】无待处理数据,跳过");
+//        }
+
+        // ---- 火运规则1 ----
+        if (!trainRule1List.isEmpty()) {
+            int[] result = executeUpdates(trainRule1List,
+                    id -> meterWorkRailwayActFirstMapper.updateFirstByRule1(id),
+                    "火运规则1", "一次表 有效→已结净");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【火运规则1】无待处理数据,跳过");
+        }
+
+        // ---- 火运规则2 ----
+        if (!trainRule2List.isEmpty()) {
+            int[] result = executeUpdates(trainRule2List,
+                    id -> meterWorkRailwayActFirstMapper.updatePredictionByRule2(id),
+                    "火运规则2", "预报表 正使用→已使用");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【火运规则2】无待处理数据,跳过");
+        }
+
+        // ---- 火运规则3 ----
+        if (!trainRule3List.isEmpty()) {
+            int[] result = executeUpdates(trainRule3List,
+                    id -> meterWorkRailwayActFirstMapper.updatePredictionByRule3(id),
+                    "火运规则3", "预报表 未使用→正使用");
+            totalSuccess += result[0];
+            totalFail += result[1];
+        } else {
+            log.info("【火运规则3】无待处理数据,跳过");
+        }
+
+        // ---- 火运规则4 ----
+//        if (!trainRule4List.isEmpty()) {
+//            int[] result = executeUpdates(trainRule4List,
+//                    id -> meterWorkRailwayActFirstMapper.updatePredictionByRule4(id),
+//                    "火运规则4", "预报表 已使用/正使用→未使用");
+//            totalSuccess += result[0];
+//            totalFail += result[1];
+//        } else {
+//            log.info("【火运规则4】无待处理数据,跳过");
+//        }
+
+        log.info("========== 状态同步完成,成功 {} 条,失败 {} 条,耗时 {}ms ==========",
+                totalSuccess, totalFail, System.currentTimeMillis() - startTime);
+    }
+
+    private int[] executeUpdates(List<String> idList, UpdateFunction updateFunc,
+                                 String ruleName, String actionDesc) {
+        int success = 0;
+        int fail = 0;
+
+        for (String id : idList) {
+            try {
+                int rows = doUpdate(id, updateFunc);
+                if (rows > 0) {
+                    success++;
+                    log.info("[{}生效] ID: {}, {},影响 {} 行", ruleName, id, actionDesc, rows);
+                } else {
+                    log.debug("[{}跳过] ID: {}, 状态已变更或条件不满足", ruleName, id);
+                }
+            } catch (Exception e) {
+                fail++;
+                log.error("[{}失败] ID: {}, 异常: {}", ruleName, id, e.getMessage(), e);
+            }
+        }
+
+        log.info("【{}】处理完成: 成功={}, 失败={}", ruleName, success, fail);
+        return new int[]{success, fail};
+    }
+
+    /**
+     * 单条更新(独立事务,超时10秒)
+     */
+    @Transactional(propagation = Propagation.REQUIRES_NEW, timeout = 10)
+    public int doUpdate(String id, UpdateFunction updateFunc) {
+        return updateFunc.apply(id);
+    }
+
+    /**
+     * 函数式接口
+     */
+    @FunctionalInterface
+    private interface UpdateFunction {
+        int apply(String id);
+    }
+}

+ 176 - 176
src/main/java/com/steerinfo/baseinfo/appverificationcode/service/impl/AppVerificationCodeServiceImpl.java

@@ -5,19 +5,19 @@ import com.steerinfo.framework.service.impl.BaseServiceImpl;
 import com.steerinfo.baseinfo.appverificationcode.model.AppVerificationCode;
 import com.steerinfo.baseinfo.appverificationcode.mapper.AppVerificationCodeMapper;
 import com.steerinfo.baseinfo.appverificationcode.service.IAppVerificationCodeService;
-import com.wellbole.sms.client.callback.InboundMessageFetchCallback;
-import com.wellbole.sms.client.callback.StatusReportMessageFetchCallback;
-import com.wellbole.sms.client.impl.HttpPostSmsClient;
-import com.wellbole.sms.client.impl.SmsFetcherImpl;
-import com.wellbole.sms.client.impl.SmsSenderImpl;
-import com.wellbole.sms.client.impl.StatusReportFetcherImpl;
-import com.wellbole.sms.client.message.InboundMessage;
-import com.wellbole.sms.client.message.OutboundMessage;
-import com.wellbole.sms.client.message.StatusReportMessage;
-import com.wellbole.sms.client.result.SmsFetchResult;
-import com.wellbole.sms.client.result.SmsSendResult;
-import com.wellbole.sms.client.service.SmsFetcherThreadService;
-import com.wellbole.sms.client.service.StatusReportFetcherThreadService;
+//import com.wellbole.sms.client.callback.InboundMessageFetchCallback;
+//import com.wellbole.sms.client.callback.StatusReportMessageFetchCallback;
+//import com.wellbole.sms.client.impl.HttpPostSmsClient;
+//import com.wellbole.sms.client.impl.SmsFetcherImpl;
+//import com.wellbole.sms.client.impl.SmsSenderImpl;
+//import com.wellbole.sms.client.impl.StatusReportFetcherImpl;
+//import com.wellbole.sms.client.message.InboundMessage;
+//import com.wellbole.sms.client.message.OutboundMessage;
+//import com.wellbole.sms.client.message.StatusReportMessage;
+//import com.wellbole.sms.client.result.SmsFetchResult;
+//import com.wellbole.sms.client.result.SmsSendResult;
+//import com.wellbole.sms.client.service.SmsFetcherThreadService;
+//import com.wellbole.sms.client.service.StatusReportFetcherThreadService;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,168 +54,168 @@ public class AppVerificationCodeServiceImpl extends BaseServiceImpl<AppVerificat
 
     @Override
     public void sendInfo(String phoneNum) throws InterruptedException{
-        Logger logger = LogManager.getLogger(AppVerificationCodeServiceImpl.class);
-
-        /*********************************************
-         * 构造基本发送数据客户端,短信发送器,短信接收器
-         ********************************************/
-        //构造基于HTTP POST方式的发送数据客户端
-        //注入方式HttpPostSmsClient实现了SmsClient接口
-        HttpPostSmsClient client = new HttpPostSmsClient();
-        client.setServerUrl("http://10.99.200.19:10086/router");
-        //f2e0d49b4f7c4735a0e3e3b9d173e5e4]
-        //以前的
-//        client.setAppKey("53e548b23a784379b6c30ec88b28c801");
-//        client.setAppSecret("c339eaa1099449fba94751649f185f63");
-        // 任学宏发我的
-        client.setAppKey("dfaeca54542e4eb99e93973aa145e82b");
-        client.setAppSecret("1c080c93037243618d5497611c21ccdb");
-
-        //构造短信发送器(平台-》用户手机)
-        //SmsSenderImpl smsSender = new SmsSenderImpl(client);
-        //注入方式,SmsSenderImpl实现了SmsSender接口
-        SmsSenderImpl smsSender = new SmsSenderImpl();
-        smsSender.setClient(client);
-
-        /*********************************************
-         * 短信发送测试
-         ********************************************/
-        //构造下行短信(平台-》用户手机)
-        OutboundMessage message = new OutboundMessage();
-        message.setPhone(phoneNum);
-        //开会通知,xxx在xxx召开xxx会议,请准时参加。
-        //系统异常报告:xxx系统于xxx 发生故障,请及时处理。
-        //message.setContent("系统异常报告:站群系统于2016-01-18 20:32:04 发生故障,请及时处理。");
-        //message.setExtCode("");
-
-        //随机生成六位数的密码
-        Integer randNum = (int)(Math.random()* (999999)+1);
-        String password = String.format("%06d",randNum);
-        //查询出有多少与phoneNum匹配的号码
-        AppVerificationCode modelTemp =  appVerificationCodeMapper.selectByPhone(phoneNum);
-
-        Calendar c = Calendar.getInstance();
-        //如果电话号码已存在,只需更新新建时间、过期时间、标志位,
-        if(appVerificationCodeMapper.selectByPhone(phoneNum) != null && modelTemp.getPhoneNo().equals(phoneNum)) {
-            //验证码有效
-            modelTemp.setValueFlag("1");
-            //验证码发送时间
-            modelTemp.setCreateTime(new Date());
-            //过期时间:当前时间后三分钟
-               //实例化
-            c.add(Calendar.MINUTE, 3);  //分钟+3
-            modelTemp.setExpirationTime(c.getTime());
-            //设置验证码
-            modelTemp.setCode(password);
-            appVerificationCodeMapper.updateByPrimaryKey(modelTemp);
-        }else{  //未查到号码直接插入验证码匹配信息
-            //生成ID
-            AppVerificationCode model = new AppVerificationCode();
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-            model.setInfoId(sdf.format(new Date()));
-            //设置电话号码
-            model.setPhoneNo(phoneNum);
-            //设置验证码
-            model.setCode(password);
-            //验证码有效
-            model.setValueFlag("1");
-            //验证码发送时间
-            model.setCreateTime(new Date());
-            //过期时间:当前时间后三分钟
-            c.add(Calendar.MINUTE, 3);
-            model.setExpirationTime(c.getTime());
-
-            appVerificationCodeMapper.insertSelective(model);
-        }
-
-        message.setContent("您的验证码是"+ password +"(3分钟之内有效),请不要把验证码泄露给其他人。如非本人操作,可不用理会");
-        //以下是可选参数
-        //默认不指定该参数,若指定,平台将返回该指定的msgid,若不指定,则由平台自动生成
-        //message.setMsgid("用户指定的id");
-        //设定发送时间,可指定未来的时间,表示延迟发送,若不指定,则默认立即发送。
-        //message.setSendAt(new Date());
-        //发送短信
-        StatusReportFetcherThreadService statusService = new StatusReportFetcherThreadService();
-        StatusReportFetcherImpl statusReportFetcher = new StatusReportFetcherImpl();
-        statusReportFetcher.setClient(client);
-        statusService.setStatusReportFetcher(statusReportFetcher);
-        statusService.setPeriod(10);
-        statusService.setStatusReportMessageFetchCallback(new StatusReportMessageFetchCallback(){
-            @Override
-            public void onFetch(StatusReportMessage msg) {
-                logger.info("phone=" + msg.getPhone());
-                logger.info("status="+msg.getStatusCode());
-            }
-        });
-        statusService.start();
-        for(int index =0 ;index < 1; index++){
-            SmsSendResult sendResult = smsSender.send(message);
-            if(sendResult != null){
-                //statusService.AddToStatusReportQueue(sendResult.getMsgid());
-            }
-            //发送结果检查
-            if(sendResult.hasError()){
-                logger.info("发送失败,原因=" + sendResult.getErrorMessage());
-            }else{
-                //发送成功时,服务器端会生成一个36字节长度的唯一标示。
-                logger.info("发送成功,服务器端返回的msgid=" +sendResult.getMsgid());
-            }
-        }
-
-        /*********************************************
-         * 短信接收测试(由调用端调用接收接口进行接收,手动模式)
-         ********************************************/
-
-
-        //构造短信接收器(用户手机-》平台)
-        //SmsFetcher smsFetcher = new SmsFetcherImpl(client);
-        //注入方式,SmsFetcherImpl实现了SmsFetcher接口
-        SmsFetcherImpl smsFetcher = new SmsFetcherImpl();
-        smsFetcher.setClient(client);
-        //获取上行短信,建议每间隔5秒以上获取一次,
-        //太频繁会造成短信服务负载过大。
-        String extCode = "";
-        SmsFetchResult fetchResult = smsFetcher.fetch(extCode);
-        if(fetchResult.hasError()){
-            logger.info("获取上行短信失败,原因=" + fetchResult.getErrorMessage());
-        }else if(fetchResult.hasData()){//有数据返回。
-            for(InboundMessage inboundMessage : fetchResult.getInboundMessageList()){
-                //msgid,平台自动生成的消息id
-                logger.info("msgid=" + inboundMessage.getMsgid());
-                //扩展代码,默认为空。
-                logger.info("extcode=" + inboundMessage.getExtCode());
-                //用户手机号码
-                logger.info("phone=" + inboundMessage.getPhone());
-                //用户发送的短信内容
-                logger.info("content=" + inboundMessage.getContent());
-                //平台接收上行短信时间
-                logger.info("receiverAt=" + inboundMessage.getReceiveAt());
-            }
-        }
-
-
-
-
-        /*********************************************
-         * 短信接收测试(内置线程自动获取方式,需要提供回调接口实现,自动模式)
-         *******************************************
-        //构造回调接口实现
-
-        //上行短信(用户手机-》平台)回调接口实现
-        InboundMessageFetchCallback callback = new InboundMessageCallbackTestImpl();
-        //构造短息获取服务线程
-        SmsFetcherThreadService fetcherService = new SmsFetcherThreadService();
-        //注入接收器(服务线程定期调用接收器来获取平台的上行短信)
-        fetcherService.setSmsFetcher(smsFetcher);
-        //每隔10秒检查一次
-        fetcherService.setPeriod(5);
-        //设定回调接口
-        fetcherService.setInboundMessageFetchCallback(callback);
-        //开始服务
-        fetcherService.start();
-        //15分钟后停止服务
-        Thread.sleep(1000);
-        fetcherService.stop();
-        statusService.stop();*/
+//        Logger logger = LogManager.getLogger(AppVerificationCodeServiceImpl.class);
+//
+//        /*********************************************
+//         * 构造基本发送数据客户端,短信发送器,短信接收器
+//         ********************************************/
+//        //构造基于HTTP POST方式的发送数据客户端
+//        //注入方式HttpPostSmsClient实现了SmsClient接口
+//        HttpPostSmsClient client = new HttpPostSmsClient();
+//        client.setServerUrl("http://10.99.200.19:10086/router");
+//        //f2e0d49b4f7c4735a0e3e3b9d173e5e4]
+//        //以前的
+////        client.setAppKey("53e548b23a784379b6c30ec88b28c801");
+////        client.setAppSecret("c339eaa1099449fba94751649f185f63");
+//        // 任学宏发我的
+//        client.setAppKey("dfaeca54542e4eb99e93973aa145e82b");
+//        client.setAppSecret("1c080c93037243618d5497611c21ccdb");
+//
+//        //构造短信发送器(平台-》用户手机)
+//        //SmsSenderImpl smsSender = new SmsSenderImpl(client);
+//        //注入方式,SmsSenderImpl实现了SmsSender接口
+//        SmsSenderImpl smsSender = new SmsSenderImpl();
+//        smsSender.setClient(client);
+//
+//        /*********************************************
+//         * 短信发送测试
+//         ********************************************/
+//        //构造下行短信(平台-》用户手机)
+//        OutboundMessage message = new OutboundMessage();
+//        message.setPhone(phoneNum);
+//        //开会通知,xxx在xxx召开xxx会议,请准时参加。
+//        //系统异常报告:xxx系统于xxx 发生故障,请及时处理。
+//        //message.setContent("系统异常报告:站群系统于2016-01-18 20:32:04 发生故障,请及时处理。");
+//        //message.setExtCode("");
+//
+//        //随机生成六位数的密码
+//        Integer randNum = (int)(Math.random()* (999999)+1);
+//        String password = String.format("%06d",randNum);
+//        //查询出有多少与phoneNum匹配的号码
+//        AppVerificationCode modelTemp =  appVerificationCodeMapper.selectByPhone(phoneNum);
+//
+//        Calendar c = Calendar.getInstance();
+//        //如果电话号码已存在,只需更新新建时间、过期时间、标志位,
+//        if(appVerificationCodeMapper.selectByPhone(phoneNum) != null && modelTemp.getPhoneNo().equals(phoneNum)) {
+//            //验证码有效
+//            modelTemp.setValueFlag("1");
+//            //验证码发送时间
+//            modelTemp.setCreateTime(new Date());
+//            //过期时间:当前时间后三分钟
+//               //实例化
+//            c.add(Calendar.MINUTE, 3);  //分钟+3
+//            modelTemp.setExpirationTime(c.getTime());
+//            //设置验证码
+//            modelTemp.setCode(password);
+//            appVerificationCodeMapper.updateByPrimaryKey(modelTemp);
+//        }else{  //未查到号码直接插入验证码匹配信息
+//            //生成ID
+//            AppVerificationCode model = new AppVerificationCode();
+//            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+//            model.setInfoId(sdf.format(new Date()));
+//            //设置电话号码
+//            model.setPhoneNo(phoneNum);
+//            //设置验证码
+//            model.setCode(password);
+//            //验证码有效
+//            model.setValueFlag("1");
+//            //验证码发送时间
+//            model.setCreateTime(new Date());
+//            //过期时间:当前时间后三分钟
+//            c.add(Calendar.MINUTE, 3);
+//            model.setExpirationTime(c.getTime());
+//
+//            appVerificationCodeMapper.insertSelective(model);
+//        }
+//
+//        message.setContent("您的验证码是"+ password +"(3分钟之内有效),请不要把验证码泄露给其他人。如非本人操作,可不用理会");
+//        //以下是可选参数
+//        //默认不指定该参数,若指定,平台将返回该指定的msgid,若不指定,则由平台自动生成
+//        //message.setMsgid("用户指定的id");
+//        //设定发送时间,可指定未来的时间,表示延迟发送,若不指定,则默认立即发送。
+//        //message.setSendAt(new Date());
+//        //发送短信
+//        StatusReportFetcherThreadService statusService = new StatusReportFetcherThreadService();
+//        StatusReportFetcherImpl statusReportFetcher = new StatusReportFetcherImpl();
+//        statusReportFetcher.setClient(client);
+//        statusService.setStatusReportFetcher(statusReportFetcher);
+//        statusService.setPeriod(10);
+//        statusService.setStatusReportMessageFetchCallback(new StatusReportMessageFetchCallback(){
+//            @Override
+//            public void onFetch(StatusReportMessage msg) {
+//                logger.info("phone=" + msg.getPhone());
+//                logger.info("status="+msg.getStatusCode());
+//            }
+//        });
+//        statusService.start();
+//        for(int index =0 ;index < 1; index++){
+//            SmsSendResult sendResult = smsSender.send(message);
+//            if(sendResult != null){
+//                //statusService.AddToStatusReportQueue(sendResult.getMsgid());
+//            }
+//            //发送结果检查
+//            if(sendResult.hasError()){
+//                logger.info("发送失败,原因=" + sendResult.getErrorMessage());
+//            }else{
+//                //发送成功时,服务器端会生成一个36字节长度的唯一标示。
+//                logger.info("发送成功,服务器端返回的msgid=" +sendResult.getMsgid());
+//            }
+//        }
+//
+//        /*********************************************
+//         * 短信接收测试(由调用端调用接收接口进行接收,手动模式)
+//         ********************************************/
+//
+//
+//        //构造短信接收器(用户手机-》平台)
+//        //SmsFetcher smsFetcher = new SmsFetcherImpl(client);
+//        //注入方式,SmsFetcherImpl实现了SmsFetcher接口
+//        SmsFetcherImpl smsFetcher = new SmsFetcherImpl();
+//        smsFetcher.setClient(client);
+//        //获取上行短信,建议每间隔5秒以上获取一次,
+//        //太频繁会造成短信服务负载过大。
+//        String extCode = "";
+//        SmsFetchResult fetchResult = smsFetcher.fetch(extCode);
+//        if(fetchResult.hasError()){
+//            logger.info("获取上行短信失败,原因=" + fetchResult.getErrorMessage());
+//        }else if(fetchResult.hasData()){//有数据返回。
+//            for(InboundMessage inboundMessage : fetchResult.getInboundMessageList()){
+//                //msgid,平台自动生成的消息id
+//                logger.info("msgid=" + inboundMessage.getMsgid());
+//                //扩展代码,默认为空。
+//                logger.info("extcode=" + inboundMessage.getExtCode());
+//                //用户手机号码
+//                logger.info("phone=" + inboundMessage.getPhone());
+//                //用户发送的短信内容
+//                logger.info("content=" + inboundMessage.getContent());
+//                //平台接收上行短信时间
+//                logger.info("receiverAt=" + inboundMessage.getReceiveAt());
+//            }
+//        }
+//
+//
+//
+//
+//        /*********************************************
+//         * 短信接收测试(内置线程自动获取方式,需要提供回调接口实现,自动模式)
+//         *******************************************
+//        //构造回调接口实现
+//
+//        //上行短信(用户手机-》平台)回调接口实现
+//        InboundMessageFetchCallback callback = new InboundMessageCallbackTestImpl();
+//        //构造短息获取服务线程
+//        SmsFetcherThreadService fetcherService = new SmsFetcherThreadService();
+//        //注入接收器(服务线程定期调用接收器来获取平台的上行短信)
+//        fetcherService.setSmsFetcher(smsFetcher);
+//        //每隔10秒检查一次
+//        fetcherService.setPeriod(5);
+//        //设定回调接口
+//        fetcherService.setInboundMessageFetchCallback(callback);
+//        //开始服务
+//        fetcherService.start();
+//        //15分钟后停止服务
+//        Thread.sleep(1000);
+//        fetcherService.stop();
+//        statusService.stop();*/
     }
 }

+ 18 - 17
src/main/java/com/steerinfo/baseinfo/appverificationcode/service/impl/InboundMessageCallbackTestImpl.java

@@ -1,7 +1,7 @@
 package com.steerinfo.baseinfo.appverificationcode.service.impl;
 
-import com.wellbole.sms.client.callback.InboundMessageFetchCallback;
-import com.wellbole.sms.client.message.InboundMessage;
+//import com.wellbole.sms.client.callback.InboundMessageFetchCallback;
+//import com.wellbole.sms.client.message.InboundMessage;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 
@@ -10,7 +10,8 @@ import org.apache.log4j.Logger;
  * @author: dyj
  * @date: 2022年03月16日11:00
  */
-public class InboundMessageCallbackTestImpl implements InboundMessageFetchCallback {
+//public class InboundMessageCallbackTestImpl implements InboundMessageFetchCallback {
+public class InboundMessageCallbackTestImpl  {
     /**
      * 日志
      */
@@ -21,18 +22,18 @@ public class InboundMessageCallbackTestImpl implements InboundMessageFetchCallba
      * TODO 简单描述该方法的实现功能(可选)
      * @see com.wellbole.sms.client.callback.InboundMessageFetchCallback#onFetch(com.wellbole.sms.client.message.InboundMessage)
      */
-    @Override
-    public void onFetch(InboundMessage inboundMessage) {
-        //inboundMessage是上行短信(用户手机-》平台)
-        //msgid,平台自动生成的消息id
-        logger.info("msgid=" + inboundMessage.getMsgid());
-        //扩展代码,默认为空。
-        logger.info("extcode=" + inboundMessage.getExtCode());
-        //用户手机号码
-        logger.info("phone=" + inboundMessage.getPhone());
-        //用户发送的短信内容
-        logger.info("content=" + inboundMessage.getContent());
-        //平台接收上行短信时间
-        logger.info("receiverAt=" + inboundMessage.getReceiveAt());
-    }
+//    @Override
+//    public void onFetch(InboundMessage inboundMessage) {
+//        //inboundMessage是上行短信(用户手机-》平台)
+//        //msgid,平台自动生成的消息id
+//        logger.info("msgid=" + inboundMessage.getMsgid());
+//        //扩展代码,默认为空。
+//        logger.info("extcode=" + inboundMessage.getExtCode());
+//        //用户手机号码
+//        logger.info("phone=" + inboundMessage.getPhone());
+//        //用户发送的短信内容
+//        logger.info("content=" + inboundMessage.getContent());
+//        //平台接收上行短信时间
+//        logger.info("receiverAt=" + inboundMessage.getReceiveAt());
+//    }
 }

+ 2 - 1
src/main/java/com/steerinfo/filter/SecurityFilter.java

@@ -43,6 +43,7 @@ public class SecurityFilter implements Filter {
                 ||path.contains("/v1/authority/getVerification")
                 ||path.contains("/v1/meterworkcaractuals/ApplikeByDesc")
                 ||path.contains("/v1/meterworkcaractualfirsts/ApplikeByDesc")
+                ||path.contains("/v1/meterworkcaractuals/testBatchcommonRemove")
                 ||"/v2/api-docs".equals(path)){
             filterChain.doFilter(servletRequest,servletResponse);
             return;
@@ -66,7 +67,7 @@ public class SecurityFilter implements Filter {
         if(vCode == null || StringUtils.isEmpty(vCode)) {
             vCode = request.getHeader("verificationCode");
         }
-        //vCode = "8ac69f685b9f389fe7ad399a6ee725a0";
+//        vCode = "3d7a923b0cb1f35d56901a289877e1de";
         //取出验证码
         if(vCode == null || StringUtils.isEmpty(vCode)) {
             response.setContentType("application/json;charset=UTF-8");

+ 22 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractual/controller/MeterWorkCarActualController.java

@@ -622,6 +622,28 @@ throw new MarkerMetException(500, "操作异常!!");
         return rm;
     }
 
+    // test,后台批处理
+    @PostMapping(value = "/testBatchcommonRemove")
+    public RESTfulResult testBatchcommonRemove(@RequestBody HashMap params) {
+
+        try {
+            int rm = meterWorkCarActualService.batchCommonRemove();
+                if (rm >= 1) {
+                    return success(rm);
+                } else {
+                    return failed("操作失败");
+                }
+        } catch (MarkerMetException e) {
+            e.printStackTrace();
+            return failed("操作失败");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return failed("操作失败");
+
+        }
+    }
+
     @ApiOperation(value = "查询计量票据录入数据")
     @PostMapping(value = "/selectManualData")
     @Transactional(rollbackFor = Exception.class)

+ 8 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractual/mapper/MeterWorkCarActualMapper.java

@@ -6,6 +6,7 @@ import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualF
 import feign.Param;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -78,4 +79,11 @@ public interface MeterWorkCarActualMapper extends IBaseMapper<MeterWorkCarActual
     List<HashMap> getNetFilterCheck(HashMap<String, Object> params);
 
     List<HashMap> getNetFilterCheckWeightReversal(HashMap<String, Object> params);
+
+    List<MeterWorkCarActual> findCommonRemove();
+
+    List<MeterWorkCarActual> selectByMapRe(HashMap<String, Object> actualInfoMap);
+
+    BigDecimal selectLastUpWeightByCarNo(String carNo);
+
 }

+ 17 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractual/mapper/MeterWorkCarActualMapper.xml

@@ -4838,5 +4838,22 @@
     </where>
     order by net_time desc
   </select>
+    <select id="findCommonRemove"  resultMap="BaseResultMap">
+      select * from METER_WORK_CAR_ACTUAL t where t.car_no in ('甘B07522','甘AQY023','甘B07268','晋B91232','晋JW5922')
+      AND TO_CHAR(T.NET_TIME,'yyyy-MM-dd') >= '2026-04-25'
+      AND TO_CHAR(T.NET_TIME,'yyyy-MM-dd') &lt;= '2026-05-25'
+      AND T.VALUE_FLAG = '1'
+    </select>
+  <select id="selectByMapRe" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    WHERE CAR_NO = #{carNo}
+    and value_flag != '0'
+    order by ACTUAL_NO desc
+    FETCH FIRST 1 ROW ONLY
+  </select>
+    <select id="selectLastUpWeightByCarNo" resultType="java.math.BigDecimal">
+      SELECT * FROM METER_WORK_CAR_ACTUAL WHERE CAR_NO = #{carNo} AND VALUE_FLAG != '0' AND prediction_Type = 1 ORDER BY NET_TIME DESC
+      FETCH FIRST 1 ROW ONLY
+    </select>
 
 </mapper>

+ 3 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractual/service/IMeterWorkCarActualService.java

@@ -119,4 +119,7 @@ public interface IMeterWorkCarActualService extends IBaseService<MeterWorkCarAct
     PageList<HashMap> getNetFilterCheck(HashMap params);
 
     PageList<HashMap> getNetFilterCheckWeightReversal(HashMap params);
+
+    int batchCommonRemove();
+
 }

+ 14 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractual/service/impl/MeterWorkCarActualServiceImpl.java

@@ -53,6 +53,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import javax.sql.DataSource;
@@ -3589,4 +3590,17 @@ public class MeterWorkCarActualServiceImpl extends BaseServiceImpl<MeterWorkCarA
         return pageInfo;
     }
 
+    @Override
+    public int batchCommonRemove() {
+        // 1. 查询要废除的结净数据
+        List<MeterWorkCarActual> carActuals = meterWorkCarActualMapper.findCommonRemove();
+        for(MeterWorkCarActual carActual : carActuals) {
+            // 2. 将结净数据作废
+            HashMap<String, Object> objectObjectHashMap = new HashMap<>();
+            objectObjectHashMap.put("note","管理员处理");
+            objectObjectHashMap.put("actualNo",carActual.getActualNo());
+            commonRemove(objectObjectHashMap);
+        }
+        return 1;
+}
 }

+ 10 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/controller/MeterWorkCarActualFirstController.java

@@ -32,6 +32,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
@@ -795,6 +796,9 @@ public class MeterWorkCarActualFirstController extends BaseRESTfulController {
     //@RequiresPermissions("meterworkcaractualfirst:create")
     @PostMapping(value = "/doUpdateWf")
     public RESTfulResult doUpdateWf(@RequestBody MeterWorkCarActualFirst model) {
+        if (model.getMeterWeight() == null || model.getMeterWeight().compareTo(BigDecimal.ZERO) == 0) {
+            return failed("过磅重量不能为0");
+        }
         RESTfulResult rm = meterWorkCarActualFirstService.doUpdateWf(model);
         return rm;
     }
@@ -804,6 +808,9 @@ public class MeterWorkCarActualFirstController extends BaseRESTfulController {
     @PostMapping(value = "/doAddInnerWf", produces = "application/json;charset=UTF-8")
     public RESTfulResult doAddInnerWf(@RequestBody CommonCombination<MeterWorkCarActualFirst, MeterWorkCarActual, MeterWorkPreLink, MeterMonitorNote> com) {
         try {
+            if (com.getOne().getMeterWeight() == null || com.getOne().getMeterWeight().compareTo(BigDecimal.ZERO) == 0) {
+                return failed("过磅重量不能为0");
+            }
             RESTfulResult rm = meterWorkCarActualFirstService.doAddInnerWf(com.getOne(), com.getSOne(), com.getFour());
             if(!rm.isSucceed()) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -821,6 +828,9 @@ public class MeterWorkCarActualFirstController extends BaseRESTfulController {
     @PostMapping(value = "/doAddNetInnerWf", produces = "application/json;charset=UTF-8")
     public RESTfulResult doAddNetInnerWf(@RequestBody CommonCombination<MeterWorkCarActualFirst, MeterWorkCarActual, MeterWorkPreLink, MeterMonitorNote> com) {
         try {
+            if (com.getOne().getMeterWeight() == null || com.getOne().getMeterWeight().compareTo(BigDecimal.ZERO) == 0) {
+                return failed("过磅重量不能为0");
+            }
             RESTfulResult rm = meterWorkCarActualFirstService.doAddNetInnerWf(com.getOne(), com.getTwo(), com.getSOne(), com.getFour());
             if(!rm.isSucceed()){
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

+ 40 - 0
src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/mapper/MeterWorkCarActualFirstMapper.java

@@ -4,6 +4,7 @@ import com.steerinfo.framework.mapper.IBaseMapper;
 import com.steerinfo.meterwork.dto.*;
 import com.steerinfo.meterwork.meterworkcaractual.model.MeterWorkCarActual;
 import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualFirst;
+import com.steerinfo.pretrack.pretrackscale.model.PreTrackScale;
 import feign.Param;
 import io.micrometer.core.instrument.Meter;
 import org.apache.ibatis.annotations.Mapper;
@@ -90,4 +91,43 @@ public interface MeterWorkCarActualFirstMapper extends IBaseMapper<MeterWorkCarA
     List<HashMap> countDayAllState(Map<String, Object> params);
     List<MeterWorkCarActualFirst> allStateView(Map<String, Object> params);
 
+    List<String> selectRule1PredictionNos();
+
+    List<String> selectRule2PredictionNos();
+
+    List<String> selectRule3PredictionNos();
+
+    List<String> selectRule4PredictionNos();
+
+    List<String> selectRule5PredictionNos();
+
+    /**
+     * 规则1:更新一次表 '有效(1)' → '已结净(2)'
+     * @param actualFirstNo 一次实绩编号
+     */
+    int updateFirstByRule1(@Param("actualFirstNo") String actualFirstNo);
+
+    /**
+     * 规则2:更新预报表 '正使用(1)' → '已使用(2)'
+     * @param predictionNo 预报编号
+     */
+    int updatePredictionByRule2(@Param("predictionNo") String predictionNo);
+
+    /**
+     * 规则3:更新预报表 '未使用(4)' → '正使用(1)'
+     * @param predictionNo 预报编号
+     */
+    int updatePredictionByRule3(@Param("predictionNo") String predictionNo);
+
+    /**
+     * 规则4:更新预报表 '正使用(1)/已使用(2)' → '未使用(4)'
+     * @param predictionNo 预报编号
+     */
+    int updatePredictionByRule4(@Param("predictionNo") String predictionNo);
+
+    /**
+     * 规则5:更新一次表 '已结净(2)' → '有效(1)'(回退)
+     * @param actualFirstNo 一次实绩编号
+     */
+    int updateFirstByRule5(@Param("actualFirstNo") String actualFirstNo);
 }

+ 156 - 4
src/main/java/com/steerinfo/meterwork/meterworkcaractualfirst/mapper/MeterWorkCarActualFirstMapper.xml

@@ -3179,10 +3179,11 @@
 
   <select id="queryForTimeInterval" parameterType="java.util.HashMap" resultMap="BaseResultMap">
     <include refid="select"/>
-    <include refid="whereLike"/>
+    WHERE CAR_NO = #{carNo}
+    AND VALUE_FLAG != '0'
+    ORDER BY CREATE_TIME DESC
+    FETCH FIRST 1 ROW ONLY
     <!--App特殊条件查询,查询不能为作废、已结净数据-->
-    and value_flag != '0'
-    order by create_time desc
   </select>
 
   <select id="ApplikeByDesc" parameterType="java.util.HashMap" resultMap="BaseResultMap">
@@ -3313,7 +3314,7 @@
     A.create_man_no,
     A.create_man_name
   </select>
-  <update id="abolishCSharp">
+    <update id="abolishCSharp">
     UPDATE METER_WORK_RAILWAY_ACT_FIRST
     SET VALUE_FLAG = '2',
         UPDATE_MAN_NO = #{userId},
@@ -3326,4 +3327,155 @@
       AND VALUE_FLAG = '1'
       AND IS_PRE_SACALE = '0'
   </update>
+  <select id="selectRule1PredictionNos"  resultType="java.lang.String">
+    SELECT FIRST.ACTUAL_FIRST_NO
+    FROM METER_WORK_CAR_ACTUAL_FIRST FIRST
+    WHERE FIRST.VALUE_FLAG = '1'
+      AND FIRST.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = FIRST.PREDICTION_NO
+      AND ACTUAL.VALUE_FLAG != '0'
+      )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule2PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_TRACK_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG = '4'
+      AND SCALE.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+    )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule3PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_TRACK_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG = '1'
+      AND SCALE.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL_FIRST FIRST
+      WHERE FIRST.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND FIRST.VALUE_FLAG = '1'
+    )
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+    )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule4PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_TRACK_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG IN ('2', '4')
+      AND SCALE.MEMO != '重置valueFlag状态位'
+  AND SCALE.CREATE_TIME >= SYSDATE - 2
+  AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL_FIRST FIRST
+      WHERE FIRST.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND FIRST.VALUE_FLAG != '0'
+  )
+  AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+  )
+FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule5PredictionNos" resultType="java.lang.String">
+    SELECT FIRST.ACTUAL_FIRST_NO
+    FROM METER_WORK_CAR_ACTUAL_FIRST FIRST
+    WHERE FIRST.VALUE_FLAG = '2'
+      AND FIRST.CREATE_TIME >= SYSDATE - 2
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = FIRST.PREDICTION_NO
+      AND ACTUAL.VALUE_FLAG != '0'
+      )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <update id="updateFirstByRule1">
+    UPDATE METER_WORK_CAR_ACTUAL_FIRST f
+    SET f.VALUE_FLAG = '2',
+        f.UPDATE_TIME = SYSDATE,
+        f.UPDATE_MAN_NAME = '修复状态'
+    WHERE f.ACTUAL_FIRST_NO = #{actualFirstNo}
+      AND f.VALUE_FLAG = '1'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL a
+      WHERE a.PREDICTION_NO = f.PREDICTION_NO
+        AND a.VALUE_FLAG != '0'
+    )
+  </update>
+
+  <!-- 规则2:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule2">
+    UPDATE PRE_TRACK_SCALE p
+    SET p.VALUE_FLAG = '2',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG = '4'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL a
+      WHERE a.PREDICTION_NO = p.PREDICTION_NO
+        AND a.VALUE_FLAG != '0'
+    )
+  </update>
+
+  <!-- 规则3:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule3">
+    UPDATE PRE_TRACK_SCALE p
+    SET p.VALUE_FLAG = '4',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG = '1'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL_FIRST f
+      WHERE f.PREDICTION_NO = p.PREDICTION_NO
+        AND f.VALUE_FLAG = '1'
+        AND NOT EXISTS (
+        SELECT 1 FROM METER_WORK_CAR_ACTUAL a
+        WHERE a.PREDICTION_NO = f.PREDICTION_NO
+        AND a.VALUE_FLAG != '0'
+      )
+    )
+  </update>
+
+  <!-- 规则4:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule4">
+    UPDATE PRE_TRACK_SCALE p
+    SET p.VALUE_FLAG = '4',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG IN ('1', '2')
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL_FIRST f
+      WHERE f.PREDICTION_NO = p.PREDICTION_NO
+    )
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL a
+      WHERE a.PREDICTION_NO = p.PREDICTION_NO
+    )
+  </update>
+
+  <!-- 规则5:用 ACTUAL_FIRST_NO 更新一次表(汽运回退) -->
+  <update id="updateFirstByRule5">
+    UPDATE METER_WORK_CAR_ACTUAL_FIRST f
+    SET f.VALUE_FLAG = '1',
+        f.UPDATE_TIME = SYSDATE,
+        f.UPDATE_MAN_NAME = '修复状态'
+    WHERE f.ACTUAL_FIRST_NO = #{actualFirstNo}
+      AND f.VALUE_FLAG = '2'
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_CAR_ACTUAL a
+      WHERE a.PREDICTION_NO = f.PREDICTION_NO
+    )
+  </update>
 </mapper>

+ 116 - 49
src/main/java/com/steerinfo/meterwork/meterworkdatacount/mapper/MeterWorkDataCountMapper.xml

@@ -442,78 +442,145 @@
 
     <select id="truckHisTareComparison" parameterType="java.util.HashMap"
             resultType="com.steerinfo.meterwork.meterworkdatacount.model.TruckHisTareComparison">
-    select
-    A.base_spot_name baseSpotName,
-            A.car_no carNo,
-           case when abs(round((A.meter_weight - B.avg_weight)/1000, 2)) > (select to_number(BASE_NAME)/1000 from com_base_info where BASE_CODE = '001067001' ) then '皮重超过偏差'
-                else '正常皮重' end alarmType,
-           round(A.meter_weight/1000, 2) meterWeight,
-           round(B.avg_weight/1000, 2) avgWeight,
-           round((A.meter_weight - B.avg_weight)/1000, 2) absoluteError,
-           round((A.meter_weight / (A.meter_weight + B.avg_weight))*100, 2) relativeError,
-           case when A.value_flag = '0' then '作废'
-                when A.value_flag = '1' then '有效'
-                when A.value_flag = '2' then '结净'
-                else null end valueFlag,
-           A.create_man_no createManNo,
-           A.create_man_name createManName,
-           A.create_time createTime,
-           A.update_man_no updateManNo,
-           A.update_man_name updateManName,
-           A.update_time updateTime,
-           case when A.meter_mode = '1' then '远程计量'
-                when A.meter_mode = '2' then '智能计量'
-                when A.meter_mode = '3' then '手工计量'
-                else null end meterMode,
-           case when A.meter_type_Name = 'SendToOutTms' then '外发'
-                when A.meter_type_Name = 'GM2GM' then '厂内转储'
-                when A.meter_type_Name = 'PO2GM' then '外进'
-                else null end meterTypeName,
-           A.note
-      from meter_work_car_actual_first A
-      left join (SELECT *
-                FROM (
-                SELECT t.*,
-                ROW_NUMBER() OVER (PARTITION BY t.car_no ORDER BY t.create_time DESC) AS rn
-                FROM meter_base_his_tare_data t
-                )
-                WHERE rn = 1) B
-        on A.car_no = B.Car_No
-     where A.weight_type = '1'
+        WITH
+        -- 1. 历史皮重表最新记录(每个车号最近一条)
+        latest_tare AS (
+        SELECT car_no, avg_weight, up_weight, tare_type,
+        ROW_NUMBER() OVER (PARTITION BY car_no ORDER BY create_time DESC) AS rn
+        FROM meter_base_his_tare_data
+        ),
+        -- 2. 洁净表最新非混装记录(排除混装/混卸)
+        latest_clean AS (
+        SELECT car_no, tare_weight AS clean_up_weight,
+        ROW_NUMBER() OVER (PARTITION BY car_no ORDER BY net_time DESC) AS rn
+        FROM meter_work_car_actual
+        WHERE PREDICTION_TYPE = 1   -- 请根据实际业务调整条件
+        ),
+        -- 3. 主关联 + 计算有效皮重及偏差
+        base_with_effective AS (
+        SELECT
+        A.base_spot_name,
+        A.car_no,
+        A.meter_weight,
+        A.value_flag,
+        A.create_man_no,
+        A.create_man_name,
+        A.create_time,
+        A.update_man_no,
+        A.update_man_name,
+        A.update_time,
+        A.meter_mode,
+        A.meter_type_Name,
+        A.note,
+        B.avg_weight,
+        B.up_weight,
+        B.tare_type,
+        C.clean_up_weight,
+        -- 有效皮重上限:当 tare_type 为 '3' 或 '4' 时取洁净皮重,否则取历史皮重
+        CASE
+        WHEN B.tare_type IN ('3', '4') THEN C.clean_up_weight
+        ELSE B.up_weight
+        END AS effectiveUpWeight,
+        -- 偏差绝对值(用于报警判断和过滤)
+        ABS(ROUND((A.meter_weight -
+        CASE
+        WHEN B.tare_type IN ('3', '4') THEN C.clean_up_weight
+        ELSE B.up_weight
+        END) / 1000, 2)) AS deviation
+        FROM meter_work_car_actual_first A
+        LEFT JOIN latest_tare B ON A.car_no = B.car_no AND B.rn = 1
+        LEFT JOIN latest_clean C ON A.car_no = C.car_no AND C.rn = 1
+        WHERE A.weight_type = '1'
+        )
+        -- 4. 最终查询:投影 + 过滤 + 排序
+        SELECT
+        base_spot_name AS baseSpotName,
+        car_no AS carNo,
+        -- 报警类型:根据 deviation 和阈值动态生成
+        CASE
+        WHEN effectiveUpWeight IS NOT NULL
+        AND deviation > (SELECT TO_NUMBER(BASE_NAME) / 1000 FROM com_base_info WHERE BASE_CODE = '001067001')
+        THEN '皮重超过偏差'
+        WHEN effectiveUpWeight IS NOT NULL THEN '正常皮重'
+        ELSE NULL
+        END AS alarmType,
+        ROUND(meter_weight / 1000, 2) AS meterWeight,
+        ROUND(avg_weight / 1000, 2) AS avgWeight,
+        ROUND(up_weight / 1000, 2) AS upWeight,
+        tare_type AS tareType,
+        ROUND((meter_weight - effectiveUpWeight) / 1000, 2) AS absoluteError,
+        ROUND((meter_weight / (meter_weight + effectiveUpWeight)) * 100, 2) AS relativeError,
+        CASE
+        WHEN value_flag = '0' THEN '作废'
+        WHEN value_flag = '1' THEN '有效'
+        WHEN value_flag = '2' THEN '结净'
+        ELSE NULL
+        END AS valueFlag,
+        create_man_no AS createManNo,
+        create_man_name AS createManName,
+        create_time AS createTime,
+        update_man_no AS updateManNo,
+        update_man_name AS updateManName,
+        update_time AS updateTime,
+        CASE
+        WHEN meter_mode = '1' THEN '远程计量'
+        WHEN meter_mode = '2' THEN '智能计量'
+        WHEN meter_mode = '3' THEN '手工计量'
+        ELSE NULL
+        END AS meterMode,
+        CASE
+        WHEN meter_type_Name = 'SendToOutTms' THEN '外发'
+        WHEN meter_type_Name = 'GM2GM' THEN '厂内转储'
+        WHEN meter_type_Name = 'PO2GM' THEN '外进'
+        ELSE NULL
+        END AS meterTypeName,
+        note,
+        effectiveUpWeight,
+        clean_up_weight AS cleanUpWeight
+        FROM base_with_effective
+        WHERE 1=1
+        <!-- 时间范围 -->
         <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
-            and  A.create_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss')
-            and A.create_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
+            AND create_time >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss')
+            AND create_time &lt;= TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
         </if>
+        <!-- 报警类型:0=超差,1=正常 -->
         <if test="alarmType != null and alarmType != ''">
             <if test="alarmType == 0">
-                and  abs(round((A.meter_weight - B.avg_weight)/1000, 2)) > (select to_number(BASE_NAME)/1000 from com_base_info where BASE_CODE = '001067001' )
+                AND deviation > (SELECT TO_NUMBER(BASE_NAME) / 1000 FROM com_base_info WHERE BASE_CODE = '001067001')
             </if>
             <if test="alarmType == 1">
-                and  abs(round((A.meter_weight - B.avg_weight)/1000, 2)) &lt;= (select to_number(BASE_NAME)/1000 from com_base_info where BASE_CODE = '001067001' )
+                AND deviation &lt;= (SELECT TO_NUMBER(BASE_NAME) / 1000 FROM com_base_info WHERE BASE_CODE = '001067001')
             </if>
         </if>
+        <!-- 车号模糊查询 -->
         <if test="carNo != null and carNo != ''">
-            and  A.car_no like '%${carNo}%'
+            AND car_no LIKE '%${carNo}%'
         </if>
+        <!-- 创建人 -->
         <if test="createManNo != null and createManNo != ''">
-            and  A.create_man_no = #{createManNo}
+            AND create_man_no = #{createManNo}
         </if>
+        <!-- 更新人 -->
         <if test="updateManNo != null and updateManNo != ''">
-            and  A.update_man_no = #{updateManNo}
+            AND update_man_no = #{updateManNo}
         </if>
+        <!-- 计量模式 -->
         <if test="meterMode != null and meterMode != ''">
-            and  A.meter_mode = #{meterMode}
+            AND meter_mode = #{meterMode}
         </if>
+        <!-- 计量类型编号 -->
         <if test="meterTypeNo != null and meterTypeNo != ''">
-            and  A.meter_type_no = #{meterTypeNo}
+            AND meter_type_no = #{meterTypeNo}
         </if>
+        <!-- 基地名称列表 -->
         <if test="baseSpotName != null and baseSpotName.size() != 0">
-            and A.base_spot_name in
+            AND base_spot_name IN
             <foreach collection="baseSpotName" item="item" open="(" separator="," close=")">
                 #{item}
             </foreach>
         </if>
-     order by A.create_time desc
+        ORDER BY create_time DESC
     </select>
 
     <select id="measurementAccuracyAnalysis" parameterType="java.util.HashMap"

+ 18 - 0
src/main/java/com/steerinfo/meterwork/meterworkdatacount/model/TruckHisTareComparison.java

@@ -9,9 +9,11 @@ public class TruckHisTareComparison {
     private String alarmType;
     private double meterWeight;
     private double avgWeight;
+    private double upWeight;
     private double absoluteError;
     private double relativeError;
     private String valueFlag;
+    private String tareType;
     private String createManNo;
     private String createManName;
     private Date createTime;
@@ -166,4 +168,20 @@ public class TruckHisTareComparison {
     public void setBase(double base) {
         this.base = base;
     }
+
+    public double getUpWeight() {
+        return upWeight;
+    }
+
+    public void setUpWeight(double upWeight) {
+        this.upWeight = upWeight;
+    }
+
+    public String getTareType() {
+        return tareType;
+    }
+
+    public void setTareType(String tareType) {
+        this.tareType = tareType;
+    }
 }

+ 2 - 1
src/main/java/com/steerinfo/meterwork/meterworkparammap/service/impl/MeterWorkParamMapService.java

@@ -69,7 +69,8 @@ public class MeterWorkParamMapService implements IMeterWorkParamMapService {
                 //计量实绩
                 HashMap<String, Object> actualInfoMap = new HashMap<>();
                 actualInfoMap.put("carNo", carNo);
-                List<MeterWorkCarActual> actualInfoList = meterWorkCarActualMapper.selectByMap(actualInfoMap);
+//                List<MeterWorkCarActual> actualInfoList = meterWorkCarActualMapper.selectByMap(actualInfoMap);
+                List<MeterWorkCarActual> actualInfoList = meterWorkCarActualMapper.selectByMapRe(actualInfoMap);
                 if(actualInfoList.size() >= 1){
                     RESTfulResult rmActual = new RESTfulResult();
                     rmActual.setData(actualInfoList);

+ 1 - 1
src/main/java/com/steerinfo/meterwork/meterworkprewgttype/service/impl/MeterWorkPreWgttypeServiceImpl.java

@@ -167,7 +167,7 @@ public class MeterWorkPreWgttypeServiceImpl extends BaseServiceImpl<MeterWorkPre
 
         HashMap<String, Object> map = new HashMap<>();
         map.put("carNo", carNo);
-        map.put("valueFlag", 1);
+        map.put("valueFlag", "1");
         List<MeterWorkPreWgttype> models = meterWorkPreWgttypeMapper.selectByParameters(map);
         if(models.size() >= 1){
             for(MeterWorkPreWgttype model: models) {

+ 16 - 0
src/main/java/com/steerinfo/meterwork/meterworkrailwayactfirst/mapper/MeterWorkRailwayActFirstMapper.java

@@ -4,6 +4,7 @@ import com.steerinfo.framework.mapper.IBaseMapper;
 import com.steerinfo.meterwork.dto.StaffPerformanceAnalysis;
 import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualFirst;
 import com.steerinfo.meterwork.meterworkrailwayactfirst.model.MeterWorkRailwayActFirst;
+import com.steerinfo.pretrack.prerailwayscale.model.PreRailwayScale;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.shiro.crypto.hash.Hash;
@@ -65,4 +66,19 @@ public interface MeterWorkRailwayActFirstMapper extends IBaseMapper<MeterWorkRai
     List<HashMap> countDayAllState(Map<String, Object> params);
 
     int abolishCSharp(String railwayNo, String userId, String userName, String startTime, String endTime);
+
+    List<String> selectRule1PredictionNos();
+
+    List<String> selectRule2PredictionNos();
+
+    List<String> selectRule3PredictionNos();
+
+    List<String> selectRule4PredictionNos();
+
+    int updateFirstByRule1(@Param("actualFirstNo") String actualFirstNo);
+    int updatePredictionByRule2(@Param("predictionNo") String predictionNo);
+    int updatePredictionByRule3(@Param("predictionNo") String predictionNo);
+    int updatePredictionByRule4(@Param("predictionNo") String predictionNo);
+
+
 }

+ 128 - 1
src/main/java/com/steerinfo/meterwork/meterworkrailwayactfirst/mapper/MeterWorkRailwayActFirstMapper.xml

@@ -4323,7 +4323,7 @@
     A.create_man_no,
     A.create_man_name
   </select>
-  <update id="abolishCSharp">
+    <update id="abolishCSharp">
     UPDATE METER_WORK_RAILWAY_ACT_FIRST
     SET VALUE_FLAG = '2',
         UPDATE_MAN_NO = #{userId},
@@ -4336,4 +4336,131 @@
       AND VALUE_FLAG = '1'
       AND IS_PRE_SACALE = '0'
   </update>
+  <select id="selectRule1PredictionNos" resultType="java.lang.String">
+    SELECT FIRST.ACTUAL_FIRST_NO
+    FROM METER_WORK_RAILWAY_ACT_FIRST FIRST
+    WHERE FIRST.VALUE_FLAG = '1'
+      AND FIRST.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = FIRST.PREDICTION_NO
+      AND ACTUAL.VALUE_FLAG != '0'
+      )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule2PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_RAILWAY_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG = '4'
+      AND SCALE.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+    )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule3PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_RAILWAY_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG = '1'
+      AND SCALE.CREATE_TIME >= SYSDATE - 2
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACT_FIRST FIRST
+      WHERE FIRST.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND FIRST.VALUE_FLAG = '1'
+    )
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+    )
+      FETCH FIRST 20 ROWS ONLY
+  </select>
+  <select id="selectRule4PredictionNos" resultType="java.lang.String">
+    SELECT SCALE.PREDICTION_NO
+    FROM PRE_RAILWAY_SCALE SCALE
+    WHERE SCALE.VALUE_FLAG IN ('2', '4')
+      AND SCALE.MEMO != '重置valueFlag状态位'   -- 排除手动重置的记录
+  AND SCALE.CREATE_TIME >= SYSDATE - 2
+  AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACT_FIRST FIRST
+      WHERE FIRST.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND FIRST.VALUE_FLAG != '0'
+  )
+  AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL ACTUAL
+      WHERE ACTUAL.PREDICTION_NO = SCALE.PREDICTION_NO
+        AND ACTUAL.VALUE_FLAG != '0'
+  )
+FETCH FIRST 20 ROWS ONLY
+  </select>
+  <update id="updateFirstByRule1">
+    UPDATE METER_WORK_RAILWAY_ACT_FIRST f
+    SET f.VALUE_FLAG = '2',
+        f.UPDATE_TIME = SYSDATE,
+        f.UPDATE_MAN_NAME = '修复状态'
+    WHERE f.ACTUAL_FIRST_NO = #{actualFirstNo}
+      AND f.VALUE_FLAG = '1'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL a
+      WHERE a.PREDICTION_NO = f.PREDICTION_NO
+        AND a.VALUE_FLAG != '0'
+    )
+  </update>
+
+  <!-- 规则2:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule2">
+    UPDATE PRE_RAILWAY_SCALE p
+    SET p.VALUE_FLAG = '2',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG = '4'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL a
+      WHERE a.PREDICTION_NO = p.PREDICTION_NO
+        AND a.VALUE_FLAG != '0'
+    )
+  </update>
+
+  <!-- 规则3:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule3">
+    UPDATE PRE_RAILWAY_SCALE p
+    SET p.VALUE_FLAG = '4',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG = '1'
+      AND EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACT_FIRST f
+      WHERE f.PREDICTION_NO = p.PREDICTION_NO
+        AND f.VALUE_FLAG = '1'
+        AND NOT EXISTS (
+        SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL a
+        WHERE a.PREDICTION_NO = f.PREDICTION_NO
+          AND a.VALUE_FLAG != '0'
+      )
+    )
+  </update>
+
+  <!-- 规则4:用 PREDICTION_NO 更新预报表 -->
+  <update id="updatePredictionByRule4">
+    UPDATE PRE_RAILWAY_SCALE p
+    SET p.VALUE_FLAG = '4',
+        p.UPDATE_TIME = SYSDATE,
+        p.UPDATE_MAN_NAME = '修复状态'
+    WHERE p.PREDICTION_NO = #{predictionNo}
+      AND p.VALUE_FLAG IN ('1', '2')
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACT_FIRST f
+      WHERE f.PREDICTION_NO = p.PREDICTION_NO
+    )
+      AND NOT EXISTS (
+      SELECT 1 FROM METER_WORK_RAILWAY_ACTUAL a
+      WHERE a.PREDICTION_NO = p.PREDICTION_NO
+    )
+  </update>
+
+
 </mapper>

+ 12 - 3
src/main/resources/application-prod.properties

@@ -77,12 +77,21 @@ multiple.datasource.master.url=jdbc:oracle:thin:@10.99.200.87:1521/jgwzjl
 multiple.datasource.master.username=lims
 multiple.datasource.master.password=lims_2021
 
-multiple.datasource.master.initial-size=15
-multiple.datasource.master.min-idle=15
+multiple.datasource.master.initial-size=50
+multiple.datasource.master.min-idle=50
 multiple.datasource.master.maxActive=75
-multiple.datasource.master.maxWait=1000
+multiple.datasource.master.maxWait=30000
 multiple.datasource.master.timeBetweenEvictionRunsMillis=60000
 multiple.datasource.master.minEvictableIdleTimeMillis=300000
+multiple.datasource.master.validationQuery=SELECT 1 FROM DUAL
+multiple.datasource.master.testWhileIdle=true
+multiple.datasource.master.testOnBorrow=false
+multiple.datasource.master.testOnReturn=false
+multiple.datasource.master.validationQueryTimeout=5
+multiple.datasource.master.remove-abandoned=true
+multiple.datasource.master.remove-abandoned-timeout=180
+multiple.datasource.master.log-abandoned=true
+
 
 #slave1
 multiple.datasource.slave1.driver-class-name=oracle.jdbc.driver.OracleDriver

+ 9 - 6
src/main/resources/application.properties

@@ -77,16 +77,19 @@ multiple.datasource.master.url=jdbc:oracle:thin:@10.99.200.87:1521/jgwzjl
 multiple.datasource.master.username=lims
 multiple.datasource.master.password=lims_2021
 
-multiple.datasource.master.initial-size=15
-multiple.datasource.master.min-idle=15
+multiple.datasource.master.initial-size=50
+multiple.datasource.master.min-idle=50
 multiple.datasource.master.maxActive=75
-multiple.datasource.master.maxWait=1000
+multiple.datasource.master.maxWait=30000
 multiple.datasource.master.timeBetweenEvictionRunsMillis=60000
 multiple.datasource.master.minEvictableIdleTimeMillis=300000
-
-#设置连接池自动回收
+multiple.datasource.master.validationQuery=SELECT 1 FROM DUAL
+multiple.datasource.master.testWhileIdle=true
+multiple.datasource.master.testOnBorrow=false
+multiple.datasource.master.testOnReturn=false
+multiple.datasource.master.validationQueryTimeout=5
 multiple.datasource.master.remove-abandoned=true
-multiple.datasource.master.remove-abandoned-timeout=5
+multiple.datasource.master.remove-abandoned-timeout=180
 multiple.datasource.master.log-abandoned=true
 
 #slave1

+ 21 - 18
src/main/resources/bootstrap.yml

@@ -15,25 +15,25 @@ spring:
 #      discovery:
 #        enabled: true
 #        service-id: config-server
-    bus:
-      trace:
-        enabled: false # 2021年9月10日取消springcloud中bus总线服务
-      enabled: false # 2021年9月10日取消springcloud中bus总线服务
+#    bus:
+#      trace:
+#        enabled: false # 2021年9月10日取消springcloud中bus总线服务
+#      enabled: false # 2021年9月10日取消springcloud中bus总线服务
 server:
   port: ${SERVER_PORT:9004}
-eureka:
-  client:
-    fetch-registry: false # 取消从注册中心获取服务信息
-    register-with-eureka: false # 取消注册服务到注册中心
-    serviceUrl:
-      defaultZone: http://root:root@${EUREKA_HOST:localhost}:${EUREKA_PORT:8061}/eureka/
-    metadata-map:
-      cluster: ribbon
-  instance:
-    hostname: system-base-pass
-    status-page-url: http://${SWAGGER_INDEX:localhost:9002}/swagger-ui.html
-    prefer-ip-address: true
-    instance-id: ${spring.cloud.client.ip-address}:${server.port}
+#eureka:
+#  client:
+#    fetch-registry: false # 取消从注册中心获取服务信息
+#    register-with-eureka: false # 取消注册服务到注册中心
+#    serviceUrl:
+#      defaultZone: http://root:root@${EUREKA_HOST:localhost}:${EUREKA_PORT:8061}/eureka/
+#    metadata-map:
+#      cluster: ribbon
+#  instance:
+#    hostname: system-base-pass
+#    status-page-url: http://${SWAGGER_INDEX:localhost:9002}/swagger-ui.html
+#    prefer-ip-address: true
+#    instance-id: ${spring.cloud.client.ip-address}:${server.port}
 #禁止调用eureka client获取注册列表信息
 ribbon:
   eureka:
@@ -43,4 +43,7 @@ management:
   endpoints:
     web:
       exposure:
-        include: '*'
+        include: '*'
+meter:
+  sync:
+    enabled: true

+ 1 - 0
src/main/resources/log4j.properties

@@ -19,6 +19,7 @@ log4j.category.market=DEBUG, steerfile
 log4j.category.com.hnshituo=DEBUG, steerfile
 #log4j.category.com.steer=${logging.level.com.steer}, steerfile
 log4j.category.com.steer=DEBUG, steerfile
+log4j.category.com.steerinfo.abnormalHandler=DEBUG, steerfile
 # com.steer下的日志输出
 log4j.appender.steerfile=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.steerfile.file=/logsdata/logs/springboot-log4j-steer.log