Browse Source

成品入仓优化

unknown 1 month ago
parent
commit
94a3ed3e2e
1 changed files with 2 additions and 51 deletions
  1. 2 51
      application/api/controller/FinishedProductWarehousing.php

+ 2 - 51
application/api/controller/FinishedProductWarehousing.php

@@ -631,8 +631,8 @@ public function getList()
             $this->error('未找到成品入仓记录');
         }
 
-        // 删除前同步中间表:MES插入类型=新增,数量取负;同步失败则不删除
-        if ($this->shouldSyncFinishStockOnDelete($old['jjcp_gdbh'], $uniqId)) {
+        // 满足同步条件才回冲:MES插入类型=新增,数量取负;不满足则正常删除
+        if ($this->shouldSyncFinishStockMiddle($old['jjcp_gdbh'])) {
             try {
                 $synchronization = new \app\api\controller\Synchronization();
                 $synchronization->syncFinishStockMiddle(
@@ -1542,55 +1542,6 @@ public function getList()
         return $exists > 0;
     }
 
-    /**
-     * 删除时是否需要回冲同步
-     * 1. 该 UniqId 已有成功同步记录/中间表数据
-     * 2. 或满足新增同步条件
-     * 3. 或工单为 Y 且 >= Y2608001(删除回冲放宽,避免 U8_06 查不到导致静默跳过)
-     * @param string $gdbh
-     * @param int $uniqId
-     * @return bool
-     */
-    protected function shouldSyncFinishStockOnDelete($gdbh, $uniqId)
-    {
-        if ($this->hasFinishStockMiddleSynced($uniqId)) {
-            return true;
-        }
-        if ($this->shouldSyncFinishStockMiddle($gdbh)) {
-            return true;
-        }
-
-        $gdbh = strtoupper(trim((string)$gdbh));
-        if ($gdbh === '' || $gdbh[0] !== 'Y') {
-            return false;
-        }
-        return (int)substr($gdbh, 1) >= 2608001;
-    }
-
-    /**
-     * 该成品入仓是否已成功同步过(日志或中间表)
-     * @param int $uniqId
-     * @return bool
-     */
-    protected function hasFinishStockMiddleSynced($uniqId)
-    {
-        $uniqId = (int)$uniqId;
-        $logCount = db('工单_成品入仓同步操作日志')
-            ->where('UniqId', $uniqId)
-            ->where('status', '同步成功')
-            ->count();
-        if ($logCount > 0) {
-            return true;
-        }
-
-        try {
-            $middleDb = Db::connect(config('database.db8'));
-            return $middleDb->name('U8_成品入仓')->where('UniqId', $uniqId)->count() > 0;
-        } catch (\Exception $e) {
-            return false;
-        }
-    }
-
     /**
      * 末版入仓后进入超节损
      * @param string $gdbh