From 8ac3affc79126b0b8ec6f4f7e80b73a6b4a4634b Mon Sep 17 00:00:00 2001
From: YYC <1833023622@qq.com>
Date: 星期四, 12 二月 2026 09:21:16 +0800
Subject: [PATCH] APP

---
 fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java |  321 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 304 insertions(+), 17 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 489f288..e3ae15f 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,8 +4,10 @@
 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;
 import com.fzzy.igds.data.InoutData;
 import com.fzzy.igds.data.InoutParam;
 import com.fzzy.igds.data.InoutPrintBill;
@@ -22,7 +24,9 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -51,14 +55,15 @@
 
     /**
      * 鍒嗛〉鏌ヨ鏁版嵁
+     *
      * @param page
      * @param param
      */
     public void listPageInout(Page<InoutRecord> page, InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
-        if(StringUtils.isBlank(param.getDeptId())){
+        if (StringUtils.isBlank(param.getDeptId())) {
             param.setDeptId(ContextUtil.subDeptId(null));
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -67,13 +72,14 @@
 
     /**
      * 鏌ヨ鏁版嵁闆嗗悎
+     *
      * @param param
      */
     public List<InoutRecord> listInout(InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
-        if(StringUtils.isBlank(param.getDeptId())){
+        if (StringUtils.isBlank(param.getDeptId())) {
             param.setDeptId(ContextUtil.subDeptId(null));
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -83,6 +89,7 @@
 
     /**
      * 灏佽鏌ヨ鏉′欢
+     *
      * @param param
      */
     public QueryWrapper<InoutRecord> getQueryWrapper(InoutParam param) {
@@ -141,14 +148,38 @@
         return queryWrapper;
     }
 
+    /**
+     * 鏍规嵁鏃堕棿绫诲瀷锛岃幏鍙栧凡瀹屾垚鐨勬甯稿崟鎹�
+     *
+     * @param timeType
+     * @param param
+     * @return
+     */
+    public List<InoutRecord> getCompleteInoutByTime(String timeType, IgdsBaseParam param) {
+        if (StringUtils.isBlank(timeType)) {
+            return null;
+        }
+
+        QueryWrapper<InoutRecord> queryWrapper = new QueryWrapper<>();
+
+        queryWrapper.likeRight("dept_id", param.getDeptId());
+        queryWrapper.likeRight("progress", Constant.PROGRESS_RECORD); //宸插畬鎴愮殑鍗曟嵁
+        queryWrapper.ne("record_status", Constant.RECORD_STATUS_DEL); //涓嶆槸鍒犻櫎鐨勫崟瀛愶紝鍗虫甯哥殑鍗曞瓙
+        queryWrapper.ge(timeType, param.getStart());
+        queryWrapper.le(timeType, param.getEnd());
+        queryWrapper.orderByAsc("complete_time");
+
+        return inoutRecordMapper.selectList(queryWrapper);
+    }
 
     /**
      * 鏌ヨ鏁版嵁
+     *
      * @param param
      * @return
      */
     public InoutRecord selectOne(InoutParam param) {
-        if(StringUtils.isBlank(param.getCompanyId())){
+        if (StringUtils.isBlank(param.getCompanyId())) {
             param.setCompanyId(ContextUtil.getCompanyId());
         }
         QueryWrapper<InoutRecord> queryWrapper = getQueryWrapper(param);
@@ -158,6 +189,7 @@
 
     /**
      * 楠岃瘉杞︾墝鍙锋槸鍚﹀湪娴佺▼涓�
+     *
      * @param companyId
      * @param plateNum
      * @return
@@ -177,6 +209,7 @@
 
     /**
      * 鎵嬪姩琛ュ崟
+     *
      * @param data
      * @return
      */
@@ -185,7 +218,7 @@
         //琛ュ崟鏁版嵁鐩存帴鍒扮粨鏋滅姸鎬�
         data.setRecordStatus(Constant.RECORD_STATUS_ADD);
         data.setProgress(Constant.PROGRESS_RECORD);
-        if(null != data.getPerWet() && data.getPerWet() > 0){
+        if (null != data.getPerWet() && data.getPerWet() > 0) {
             data.setCheckStatus(Constant.STATUS_CHECK);
         }
         String loginUser = ContextUtil.getLoginUserName();
@@ -227,6 +260,24 @@
     /**
      * 鏂板鍑哄叆搴撹褰�
      *
+     * @param list
+     * @return
+     */
+    public String addInoutRecordList(List<InoutRecord> list) {
+        if (null == list || list.isEmpty()) {
+            return "鏂板澶辫触";
+        }
+
+        for (InoutRecord inoutRecord : list) {
+            addInoutRecord(inoutRecord);
+        }
+
+        return null;
+    }
+
+    /**
+     * 鏂板鍑哄叆搴撹褰�
+     *
      * @param data
      * @return
      */
@@ -238,7 +289,7 @@
                 data.setId("R_" + id);
             } else if (Constant.TYPE_OUT.equals(data.getType())) {
                 data.setId("C_" + id);
-            }else {
+            } else {
                 data.setId("M_" + id);
             }
         }
@@ -249,9 +300,9 @@
 
         int num = inoutRecordMapper.insert(data);
         //TODO 鏇存柊缂撳瓨
-        //updateInoutCache(data);
+
         return num;
-        
+
     }
 
     /**
@@ -273,7 +324,241 @@
     }
 
     /**
+     * 鏁版嵁淇敼锛屼繚鐣欎慨鏀硅褰�
+     *
+     * @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);
+    }
+
+    /**
      * 寮傚父缁堟
+     *
      * @param data
      * @return
      */
@@ -297,15 +582,16 @@
 
         //TODO 鍒犻櫎缂撳瓨
 
-        if(i > 0){
+        if (i > 0) {
             return null;
-        }else {
+        } else {
             return "鎿嶄綔澶辫触锛�";
         }
     }
 
     /**
      * 鍑哄叆搴撴祦绋婭D鍒涘缓 202001030001 202001030001
+     *
      * @param registerTime
      * @param companyId
      * @return
@@ -369,6 +655,7 @@
 
     /**
      * 鏌ヨ鏈�澶d鍙凤紝涓虹┖鍒欒繑鍥瀗ull
+     *
      * @param companyId
      * @param timeKey
      * @return
@@ -385,9 +672,9 @@
         queryWrapper.orderByDesc("create_time");
 
         List<InoutRecord> inoutRecords = inoutRecordMapper.selectList(queryWrapper);
-        if(null == inoutRecords || inoutRecords.isEmpty()){
+        if (null == inoutRecords || inoutRecords.isEmpty()) {
             return null;
-        }else {
+        } else {
             return inoutRecords.get(0).getId();
         }
     }
@@ -401,7 +688,7 @@
     public String inWeightBill(InoutRecord data) {
 
         // 鑾峰彇琛ㄥ崟鏁版嵁
-        InoutPrintBill bill = this.createBillData(data, "鍏ュ簱鍒掔爜鍗�");
+        InoutPrintBill bill = this.createBillData(data, "-鍏ュ簱鍗�");
 
         // 璋冩暣妯$増鏁版嵁骞惰繑鍥�
         String htmlStr = InoutBill.IN_WEIGHT_DEFAULT;
@@ -453,7 +740,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());
@@ -483,7 +770,7 @@
      */
     public String outWeightBill(InoutRecord data) {
         // 鑾峰彇琛ㄥ崟鏁版嵁
-        InoutPrintBill bill = this.createBillData(data, "鍑哄簱鍒掔爜鍗�");
+        InoutPrintBill bill = this.createBillData(data, "-鍑哄簱鍗�");
 
         //榛樿妯$増
         String htmlStr = InoutBill.OUT_WEIGHT_DEFAULT;
@@ -516,7 +803,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()));

--
Gitblit v1.9.3