From 5790d7573a83278667878e0f73104f8fc8ec5cf3 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期二, 10 三月 2026 11:03:51 +0800
Subject: [PATCH] 巡检统计信息纠正

---
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java |  275 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 256 insertions(+), 19 deletions(-)

diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
index 7b8097e..6413c9d 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fzzy.igds.bill.InoutBill;
 import com.fzzy.igds.constant.Constant;
+import com.fzzy.igds.constant.FoodLevel;
 import com.fzzy.igds.constant.FoodVariety;
 import com.fzzy.igds.constant.RedisConst;
 import com.fzzy.igds.data.IgdsBaseParam;
@@ -135,26 +136,27 @@
             queryWrapper.eq("settle_tag", param.getSettleTag());
         }
         if (null != param.getStart()) {
-            queryWrapper.ge("create_time", DateUtil.getCurZero(param.getStart()));
+            queryWrapper.ge("complete_time", DateUtil.getCurZero(param.getStart()));
         }
         if (null != param.getEnd()) {
-            queryWrapper.le("create_time", DateUtil.getNextZero(param.getEnd()));
+            queryWrapper.le("complete_time", DateUtil.getNextZero(param.getEnd()));
         }
         queryWrapper.ne("record_status", Constant.RECORD_STATUS_DEL); //涓嶆槸鍒犻櫎鐨勫崟瀛愶紝鍗虫甯哥殑鍗曞瓙
-        queryWrapper.orderByDesc("create_time");
+        queryWrapper.orderByDesc("complete_time");
 
         return queryWrapper;
     }
 
     /**
      * 鏍规嵁鏃堕棿绫诲瀷锛岃幏鍙栧凡瀹屾垚鐨勬甯稿崟鎹�
+     *
      * @param timeType
      * @param param
      * @return
      */
     public List<InoutRecord> getCompleteInoutByTime(String timeType, IgdsBaseParam param) {
-        if(StringUtils.isBlank(timeType)){
-             return null;
+        if (StringUtils.isBlank(timeType)) {
+            return null;
         }
 
         QueryWrapper<InoutRecord> queryWrapper = new QueryWrapper<>();
@@ -261,7 +263,7 @@
      * @return
      */
     public String addInoutRecordList(List<InoutRecord> list) {
-        if(null == list || list.isEmpty()){
+        if (null == list || list.isEmpty()) {
             return "鏂板澶辫触";
         }
 
@@ -297,7 +299,7 @@
 
         int num = inoutRecordMapper.insert(data);
         //TODO 鏇存柊缂撳瓨
-        //updateInoutCache(data);
+
         return num;
 
     }
@@ -318,6 +320,239 @@
         //updateInoutCache(data);
         return num;
 
+    }
+
+    /**
+     * 鏁版嵁淇敼锛屼繚鐣欎慨鏀硅褰�
+     *
+     * @param updateData
+     * @return
+     */
+    public int checkAndUpdate(InoutRecord updateData) {
+
+        //鑾峰彇鍘熸潵鐨勬暟鎹�
+        InoutParam param = new InoutParam();
+        param.setId(updateData.getId());
+        InoutRecord record = this.selectOne(param);
+
+        String updateLog = checkRemarks(updateData, record);
+        updateData.setUpdateLog(updateLog);
+
+        return updateInoutRecord(updateData);
+    }
+
+    /**
+     * 鏍¢獙淇敼淇℃伅
+     *
+     * @param updateData 淇敼鏁版嵁
+     * @param record     鍘熷鏁版嵁
+     * @return
+     */
+    public String checkRemarks(InoutRecord updateData, InoutRecord record) {
+
+        String updateLog0 = "銆�" + ContextUtil.getLoginUserName() + "銆戜簬[" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss") + "]淇敼鏁版嵁锛�";
+        String updateLog = "";
+
+        boolean updateTag = false;
+        //鏍¢獙浠撳簱淇℃伅
+        if (null != updateData.getDepotId() && null != record.getDepotId()) {
+            updateTag = !updateData.getDepotId().equals(record.getDepotId());
+            if (updateTag) {
+                updateLog += "[浠撳簱缂栫爜](" + record.getDepotId() + ")淇敼涓�(" + updateData.getDepotId() + "),";
+            }
+        }
+
+        //鏍¢獙鍝佺淇℃伅
+        if (null != updateData.getFoodVariety() && null != record.getFoodVariety()) {
+            updateTag = !updateData.getFoodVariety().equals(record.getFoodVariety());
+            if (updateTag) {
+                updateLog += "[鍝佺](" + FoodVariety.getMsg(record.getFoodVariety()) + ")淇敼涓�(" + FoodVariety.getMsg(updateData.getFoodVariety()) + "),";
+            }
+        }
+
+        //绮浜у湴
+        if (null != updateData.getFoodLocation() && null != record.getFoodLocation()) {
+            updateTag = !updateData.getFoodLocation().equals(record.getFoodLocation());
+            if (updateTag) {
+                updateLog += "[绮浜у湴](" + record.getFoodLocation() + ")淇敼涓�(" + updateData.getFoodLocation() + "),";
+            }
+        }
+
+        //绮绛夌骇
+        if (null != updateData.getFoodLevel() && null != record.getFoodLevel()) {
+            updateTag = !updateData.getFoodLevel().equals(record.getFoodLevel());
+            if (updateTag) {
+                updateLog += "[绮绛夌骇](" + FoodLevel.getMsg(record.getFoodLevel()) + ")淇敼涓�(" + FoodLevel.getMsg(updateData.getFoodLevel()) + "),";
+            }
+        }
+
+        //绮骞翠唤
+        if (null != updateData.getFoodYear() && null != record.getFoodYear()) {
+            updateTag = !updateData.getFoodYear().equals(record.getFoodYear());
+            if (updateTag) {
+                updateLog += "[绮骞翠唤](" + record.getFoodYear() + ")淇敼涓�(" + updateData.getFoodYear() + "),";
+            }
+        }
+
+        //鎵胯繍浜�
+        if (null != updateData.getUserName() && null != record.getUserName()) {
+            updateTag = !updateData.getUserName().equals(record.getUserName());
+            if (updateTag) {
+                updateLog += "[鎵胯繍浜篯(" + record.getUserName() + ")淇敼涓�(" + updateData.getUserName() + "),";
+            }
+        }
+
+        //鏍¢獙閫氱煡鍗曚俊鎭�
+        if (null != updateData.getNoticeId() && null != record.getNoticeId()) {
+            updateTag = !updateData.getNoticeId().equals(record.getNoticeId());
+            if (updateTag) {
+                updateLog += "[閫氱煡鍗曠紪鐮乚(" + record.getNoticeId() + ")淇敼涓�(" + updateData.getNoticeId() + "),";
+            }
+        }
+
+        //鏍¢獙寰�鏉ュ崟浣嶄俊鎭�
+        if (null != updateData.getCustomerName() && null != record.getCustomerName()) {
+            updateTag = !updateData.getCustomerName().equals(record.getCustomerName());
+            if (updateTag) {
+                updateLog += "[寰�鏉ュ崟浣峕(" + record.getCustomerName() + ")淇敼涓�(" + updateData.getCustomerName() + "),";
+            }
+        }
+
+        //鍗曚环
+        if (null != updateData.getPrice() && null != record.getPrice()) {
+            updateTag = !updateData.getPrice().equals(record.getPrice());
+            if (updateTag) {
+                updateLog += "[鍗曚环](" + record.getPrice() + ")淇敼涓�(" + updateData.getPrice() + "),";
+            }
+        }
+
+        //缁撶畻閲戦
+        if (null != updateData.getSettleMoney() && null != record.getSettleMoney()) {
+            updateTag = !updateData.getSettleMoney().equals(record.getSettleMoney());
+            if (updateTag) {
+                updateLog += "[缁撶畻閲戦](" + record.getSettleMoney() + ")淇敼涓�(" + updateData.getSettleMoney() + "),";
+            }
+        }
+
+        //姘村垎
+        if (null != updateData.getPerWet() && null != record.getPerWet()) {
+            updateTag = !updateData.getPerWet().equals(record.getPerWet());
+            if (updateTag) {
+                updateLog += "[姘村垎](" + record.getPerWet() + ")淇敼涓�(" + updateData.getPerWet() + "),";
+            }
+        }
+
+        //鏉傝川
+        if (null != updateData.getPerImpurity() && null != record.getPerImpurity()) {
+            updateTag = !updateData.getPerImpurity().equals(record.getPerImpurity());
+            if (updateTag) {
+                updateLog += "[鏉傝川](" + record.getPerImpurity() + ")淇敼涓�(" + updateData.getPerImpurity() + "),";
+            }
+        }
+
+        //姣涢噸
+        if (null != updateData.getFullWeight() && null != record.getFullWeight()) {
+            updateTag = !updateData.getFullWeight().equals(record.getFullWeight());
+            if (updateTag) {
+                updateLog += "[姣涢噸](" + record.getFullWeight() + ")淇敼涓�(" + updateData.getFullWeight() + "),";
+            }
+        }
+
+        //鐨噸
+        if (null != updateData.getEmptyWeight() && null != record.getEmptyWeight()) {
+            updateTag = !updateData.getEmptyWeight().equals(record.getEmptyWeight());
+            if (updateTag) {
+                updateLog += "[鐨噸](" + record.getEmptyWeight() + ")淇敼涓�(" + updateData.getEmptyWeight() + "),";
+            }
+        }
+
+        //鎵i噸
+        if (null != updateData.getDeOther() && null != record.getDeOther()) {
+            updateTag = !updateData.getDeOther().equals(record.getDeOther());
+            if (updateTag) {
+                updateLog += "[鎵i噸](" + record.getDeOther() + ")淇敼涓�(" + updateData.getDeOther() + "),";
+            }
+        }
+
+        //缁撶畻閲嶉噺
+        if (null != updateData.getSettleWeight() && null != record.getSettleWeight()) {
+            updateTag = !updateData.getSettleWeight().equals(record.getSettleWeight());
+            if (updateTag) {
+                updateLog += "[缁撶畻閲嶉噺](" + record.getSettleWeight() + ")淇敼涓�(" + updateData.getSettleWeight() + "),";
+            }
+        }
+
+        //鍑哄叆搴撻噸閲�
+        if (null != updateData.getRecordWeight() && null != record.getRecordWeight()) {
+            updateTag = !updateData.getRecordWeight().equals(record.getRecordWeight());
+            if (updateTag) {
+                updateLog += "[鍑哄叆搴撻噸閲廬(" + record.getRecordWeight() + ")淇敼涓�(" + updateData.getRecordWeight() + "),";
+            }
+        }
+
+        //鐧昏鏃堕棿
+        if (null != updateData.getRegisterTime() && null != record.getRegisterTime()) {
+            updateTag = !updateData.getRegisterTime().equals(record.getRegisterTime());
+            if (updateTag) {
+                updateLog += "[鐧昏鏃堕棿](" + DateFormatUtils.format(record.getRegisterTime(), "yyyy-MM-dd HH:mm:ss") + ")淇敼涓�(" + DateFormatUtils.format(updateData.getRegisterTime(), "yyyy-MM-dd HH:mm:ss") + "),";
+            }
+        }
+
+        //婊¤溅鏃堕棿
+        if (null != updateData.getFullWeightTime() && null != record.getFullWeightTime()) {
+            updateTag = !updateData.getFullWeightTime().equals(record.getFullWeightTime());
+            if (updateTag) {
+                updateLog += "[婊¤溅鏃堕棿](" + DateFormatUtils.format(record.getFullWeightTime(), "yyyy-MM-dd HH:mm:ss") + ")淇敼涓�(" + DateFormatUtils.format(updateData.getFullWeightTime(), "yyyy-MM-dd HH:mm:ss") + "),";
+            }
+        }
+
+        //绌鸿溅鏃堕棿
+        if (null != updateData.getEmptyWeightTime() && null != record.getEmptyWeightTime()) {
+            updateTag = !updateData.getEmptyWeightTime().equals(record.getEmptyWeightTime());
+            if (updateTag) {
+                updateLog += "[绌鸿溅鏃堕棿](" + DateFormatUtils.format(record.getEmptyWeightTime(), "yyyy-MM-dd HH:mm:ss") + ")淇敼涓�(" + DateFormatUtils.format(updateData.getEmptyWeightTime(), "yyyy-MM-dd HH:mm:ss") + "),";
+            }
+        }
+
+        //瀹屾垚鏃堕棿
+        if (null != updateData.getCompleteTime() && null != record.getCompleteTime()) {
+            updateTag = !updateData.getCompleteTime().equals(record.getCompleteTime());
+            if (updateTag) {
+                updateLog += "[瀹屾垚鏃堕棿](" + DateFormatUtils.format(record.getCompleteTime(), "yyyy-MM-dd HH:mm:ss") + ")淇敼涓�(" + DateFormatUtils.format(updateData.getCompleteTime(), "yyyy-MM-dd HH:mm:ss") + "),";
+            }
+        }
+
+        //婊¤溅绉伴噸浜�
+        if (null != updateData.getFullWeightUser() && null != record.getFullWeightUser()) {
+            updateTag = !updateData.getFullWeightUser().equals(record.getFullWeightUser());
+            if (updateTag) {
+                updateLog += "[婊¤溅绉伴噸浜篯(" + record.getFullWeightUser() + ")淇敼涓�(" + updateData.getFullWeightUser() + "),";
+            }
+        }
+
+        //绌鸿溅绉伴噸浜�
+        if (null != updateData.getEmptyWeightUser() && null != record.getEmptyWeightUser()) {
+            updateTag = !updateData.getEmptyWeightUser().equals(record.getEmptyWeightUser());
+            if (updateTag) {
+                updateLog += "[绌鸿溅绉伴噸浜篯(" + record.getEmptyWeightUser() + ")淇敼涓�(" + updateData.getEmptyWeightUser() + "),";
+            }
+        }
+
+        //澶囨敞璇存槑
+        if (null != updateData.getRemarks() && null != record.getRemarks()) {
+            updateTag = !updateData.getRemarks().equals(record.getRemarks());
+            if (updateTag) {
+                updateLog += "[澶囨敞璇存槑](" + record.getRemarks() + ")淇敼涓�(" + updateData.getRemarks() + "),";
+            }
+        }
+
+        if (StringUtils.isBlank(updateLog)) {
+            return record.getUpdateLog() == null ? "" : record.getUpdateLog();
+        }
+
+        updateLog0 = updateLog0 + updateLog;
+
+        return record.getUpdateLog() == null ? updateLog0 : (record.getUpdateLog() + "锛�" + updateLog0);
     }
 
     /**
@@ -452,10 +687,10 @@
     public String inWeightBill(InoutRecord data) {
 
         // 鑾峰彇琛ㄥ崟鏁版嵁
-        InoutPrintBill bill = this.createBillData(data, "鍏ュ簱鍒掔爜鍗�");
+        InoutPrintBill bill = this.createBillData(data, "鍏ュ簱鍗�");
 
         // 璋冩暣妯$増鏁版嵁骞惰繑鍥�
-        String htmlStr = InoutBill.IN_WEIGHT_DEFAULT;
+        String htmlStr = InoutBill.IN_WEIGHT_DEFAULT_NEW;
 
         htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
 
@@ -504,7 +739,7 @@
         htmlStr = htmlStr.replace("impurity", bill.getImpurity() + "");
 
         htmlStr = htmlStr.replace("checkStatus", bill.getCheckStatus());
-        htmlStr = htmlStr.replace("remark", bill.getRemark());
+        htmlStr = htmlStr.replace("remark", "");
         htmlStr = htmlStr.replace("moneyName", bill.getMoneyName());
 
         htmlStr = htmlStr.replace("unitName", bill.getUnitName());
@@ -513,7 +748,7 @@
         htmlStr = htmlStr.replace("handleEnd", "");
         htmlStr = htmlStr.replace("noticeId", bill.getNoticeId() == null ? "" : bill.getNoticeId());
         htmlStr = htmlStr.replace("phone", data.getUserContact() == null ? "" : data.getUserContact() + "");
-        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm"));
+        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
 
         htmlStr = htmlStr.replaceAll("weightUser",
                 bill.getWeightUser() == null ? "" : bill.getWeightUser());
@@ -521,7 +756,7 @@
                 bill.getHandleUser() == null ? "" : bill.getHandleUser());
         htmlStr = htmlStr.replaceAll("keeperName",
                 bill.getKeeperUser() == null ? "" : bill.getKeeperUser());
-
+        htmlStr = htmlStr.replaceAll("createUser",ContextUtil.getLoginUserName());
 
         return htmlStr;
     }
@@ -534,10 +769,10 @@
      */
     public String outWeightBill(InoutRecord data) {
         // 鑾峰彇琛ㄥ崟鏁版嵁
-        InoutPrintBill bill = this.createBillData(data, "鍑哄簱鍒掔爜鍗�");
+        InoutPrintBill bill = this.createBillData(data, "鍑哄簱鍗�");
 
         //榛樿妯$増
-        String htmlStr = InoutBill.OUT_WEIGHT_DEFAULT;
+        String htmlStr = InoutBill.OUT_WEIGHT_DEFAULT_NEW;
 
         htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
 
@@ -567,7 +802,7 @@
                 new DecimalFormat("0.00").format(bill.getNetWeight()));
         htmlStr = htmlStr.replace("dePackage",
                 new DecimalFormat("0.00").format(bill.getDePackage()));
-        htmlStr = htmlStr.replace("remark", bill.getRemark());
+        htmlStr = htmlStr.replace("remark", "");
 
         htmlStr = htmlStr.replace("settleWeight",
                 new DecimalFormat("0.00").format(bill.getSettleWeight()));
@@ -586,11 +821,13 @@
         htmlStr = htmlStr.replace("handleEnd", "");
         htmlStr = htmlStr.replace("noticeId", bill.getNoticeId() == null ? "" : bill.getNoticeId());
         htmlStr = htmlStr.replace("phone", data.getUserContact() == null ? "" : data.getUserContact() + "");
-        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm"));
+        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
 
         htmlStr = htmlStr.replaceAll("weightUser", getValue(bill.getWeightUser()));
         htmlStr = htmlStr.replace("handleUser", getValue(bill.getHandleUser()));
         htmlStr = htmlStr.replaceAll("keeperName", getValue(bill.getKeeperUser()));
+        htmlStr = htmlStr.replaceAll("createUser",ContextUtil.getLoginUserName());
+
         return htmlStr;
     }
 
@@ -626,13 +863,13 @@
             data.setRegisterTime(new Date());
         }
         bill.setRegisterTime(DateFormatUtils.format(data.getRegisterTime(),
-                "yyyy-MM-dd HH:mm"));
+                "yyyy-MM-dd HH:mm:ss"));
 
         if (null == data.getCompleteTime()) {
             data.setCompleteTime(new Date());
         }
         bill.setCompleteTime(DateFormatUtils.format(data.getCompleteTime(),
-                "yyyy-MM-dd HH:mm"));
+                "yyyy-MM-dd HH:mm:ss"));
 
         bill.setEmptyTime(DateFormatUtils.format(data.getEmptyWeightTime(),
                 "yyyy-MM-dd HH:mm:ss"));
@@ -686,7 +923,7 @@
                 data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice() * data.getRecordWeight(), 2));
             }
         }
-        bill.setSettleMoney(data.getSettleMoney() == null ? "" : data.getSettleMoney() + "");
+        bill.setSettleMoney(data.getSettleMoney() == null ? "" : String.format("%.2f", data.getSettleMoney()));
         bill.setRemark(data.getRemarks() == null ? "" : data.getRemarks());
 
         if (Constant.TYPE_IN.equals(data.getType())) {

--
Gitblit v1.9.3