|
|
@@ -502,7 +502,7 @@ public function getList()
|
|
|
|
|
|
/**
|
|
|
* 修改
|
|
|
- * 前端仅传:UniqId、数量(jjcp_sl)、smb(jjcp_smb)、sys_id(Sys_id)
|
|
|
+ * 前端传:UniqId、数量(jjcp_sl)、smb(jjcp_smb)、sys_id(Sys_id)、时间(jjcp_sj)
|
|
|
* @ApiMethod (POST)
|
|
|
*/
|
|
|
public function edit()
|
|
|
@@ -525,8 +525,9 @@ public function getList()
|
|
|
|
|
|
$hasQty = array_key_exists('jjcp_sl', $req) || array_key_exists('数量', $req);
|
|
|
$hasSmb = array_key_exists('jjcp_smb', $req) || array_key_exists('smb', $req);
|
|
|
+ $hasSj = array_key_exists('jjcp_sj', $req);
|
|
|
$sysId = $req['Sys_id'] ?? ($req['sys_id'] ?? null);
|
|
|
- if (!$hasQty && !$hasSmb && ($sysId === null || $sysId === '')) {
|
|
|
+ if (!$hasQty && !$hasSmb && !$hasSj && ($sysId === null || $sysId === '')) {
|
|
|
$this->error('参数错误', '', 111);
|
|
|
}
|
|
|
|
|
|
@@ -534,6 +535,9 @@ public function getList()
|
|
|
if ($sysId !== null && $sysId !== '') {
|
|
|
$data['Sys_id'] = $sysId;
|
|
|
}
|
|
|
+ if ($hasSj) {
|
|
|
+ $data['jjcp_sj'] = $req['jjcp_sj'];
|
|
|
+ }
|
|
|
|
|
|
$oldQty = (float)$old['jjcp_sl'];
|
|
|
$newQty = $oldQty;
|
|
|
@@ -553,6 +557,11 @@ public function getList()
|
|
|
$smbChanged = trim($newSmb) !== trim($oldSmb);
|
|
|
}
|
|
|
|
|
|
+ $sjChanged = false;
|
|
|
+ if ($hasSj) {
|
|
|
+ $sjChanged = trim((string)$req['jjcp_sj']) !== trim((string)$old['jjcp_sj']);
|
|
|
+ }
|
|
|
+
|
|
|
// 改为末板时,校验同工单同印件是否已有其他末板记录
|
|
|
if ($smbChanged && $this->isEndBoard($newSmb)) {
|
|
|
$existingEndBoard = $this->findExistingEndBoard($old['jjcp_gdbh'], $old['jjcp_yjno']);
|
|
|
@@ -582,16 +591,16 @@ public function getList()
|
|
|
|
|
|
// 同步中间表:
|
|
|
// - 数量变更:插入差值为新同步数据(增加为正、减少为负)
|
|
|
- // - 仅修改 smb:正常同步完整数量
|
|
|
- // - 二者同时改:只同步差值(此时记录已是新 smb,中间表会带上末板标记)
|
|
|
- if ($this->shouldSyncFinishStockMiddle($old['jjcp_gdbh']) && ($qtyChanged || $smbChanged)) {
|
|
|
+ // - 仅修改 smb / 时间:正常同步完整数量
|
|
|
+ // - 数量与其他同时改:只同步差值
|
|
|
+ if ($this->shouldSyncFinishStockMiddle($old['jjcp_gdbh']) && ($qtyChanged || $smbChanged || $sjChanged)) {
|
|
|
try {
|
|
|
$synchronization = new \app\api\controller\Synchronization();
|
|
|
if ($qtyChanged) {
|
|
|
$qtyDiff = $newQty - $oldQty; // 增加为正,减少为负
|
|
|
- $synchronization->syncFinishStockMiddle($uniqId, '修改', $qtyDiff);
|
|
|
+ $synchronization->syncFinishStockMiddle($uniqId, '修改', $qtyDiff, $sysId);
|
|
|
} else {
|
|
|
- $synchronization->syncFinishStockMiddle($uniqId, '修改');
|
|
|
+ $synchronization->syncFinishStockMiddle($uniqId, '修改', null, $sysId);
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
$this->error('成品入仓已保存,但' . $e->getMessage(), ['UniqId' => $uniqId]);
|