|
|
@@ -458,11 +458,14 @@ public function getList()
|
|
|
$mongodb = Db::connect(config('database.mongodb'));
|
|
|
$this->saveFinishStock($data, $mongodb);
|
|
|
|
|
|
- try {
|
|
|
- $synchronization = new \app\api\controller\Synchronization();
|
|
|
- $synchronization->syncFinishStockMiddle($data['UniqId'], '新增');
|
|
|
- } catch (\Exception $e) {
|
|
|
- $this->error('成品入仓已保存,但' . $e->getMessage(), ['UniqId' => $data['UniqId']]);
|
|
|
+ // Y2608001 及以后工单才同步中间表,更早工单不同步
|
|
|
+ if ($this->shouldSyncFinishStockMiddle($data['jjcp_gdbh'])) {
|
|
|
+ try {
|
|
|
+ $synchronization = new \app\api\controller\Synchronization();
|
|
|
+ $synchronization->syncFinishStockMiddle($data['UniqId'], '新增');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->error('成品入仓已保存,但' . $e->getMessage(), ['UniqId' => $data['UniqId']]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($this->isEndBoard($data['jjcp_smb'])) {
|
|
|
@@ -565,11 +568,15 @@ public function getList()
|
|
|
}
|
|
|
if($bool===false) $this->error('失败');
|
|
|
|
|
|
- try {
|
|
|
- $synchronization = new \app\api\controller\Synchronization();
|
|
|
- $synchronization->syncFinishStockMiddle($req['UniqId'], '修改');
|
|
|
- } catch (\Exception $e) {
|
|
|
- $this->error('成品入仓已保存,但' . $e->getMessage(), ['UniqId' => $req['UniqId']]);
|
|
|
+ $gdbh = isset($data['jjcp_gdbh']) ? $data['jjcp_gdbh'] : db('成品入仓')->where('UniqId', $req['UniqId'])->value('jjcp_gdbh');
|
|
|
+ // Y2608001 及以后工单才同步中间表,更早工单不同步
|
|
|
+ if ($this->shouldSyncFinishStockMiddle($gdbh)) {
|
|
|
+ try {
|
|
|
+ $synchronization = new \app\api\controller\Synchronization();
|
|
|
+ $synchronization->syncFinishStockMiddle($req['UniqId'], '修改');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->error('成品入仓已保存,但' . $e->getMessage(), ['UniqId' => $req['UniqId']]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$oederLoss = new \app\api\controller\OrderSuperLoss();
|
|
|
@@ -1475,6 +1482,21 @@ public function getList()
|
|
|
return strpos((string)$smb, '末') !== false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否需要同步成品入仓中间表
|
|
|
+ * 规则:工单编号以 Y 开头,格式为 Y + 年月(YYMM) + 流水号;仅 Y2608001 及以后同步
|
|
|
+ * @param string $gdbh
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ protected function shouldSyncFinishStockMiddle($gdbh)
|
|
|
+ {
|
|
|
+ $gdbh = strtoupper(trim((string)$gdbh));
|
|
|
+ if ($gdbh === '' || $gdbh[0] !== 'Y') {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return (int)substr($gdbh, 1) >= 2608001;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 末版入仓后进入超节损
|
|
|
* @param string $gdbh
|