|
|
@@ -1016,7 +1016,7 @@ class WorkOrderSpotCheck extends Api{
|
|
|
->find();
|
|
|
|
|
|
// if (empty($res)) {
|
|
|
- $ci_num = $paramArray[4];
|
|
|
+ $ci_num = $paramArray[4];
|
|
|
// } else {
|
|
|
// $ci_num = $res["ci_num"];
|
|
|
// }
|
|
|
@@ -1189,8 +1189,6 @@ class WorkOrderSpotCheck extends Api{
|
|
|
case '总检':
|
|
|
//判断是否为子订单编号【$order:DC2503291-0703 子订单编号】
|
|
|
if (strpos($order, '-') !== false) {
|
|
|
- //子订单编号
|
|
|
-
|
|
|
// 定义查询字段
|
|
|
$field = "
|
|
|
y.订单编号, y.子订单编号, y.款号, j.款式, y.颜色,
|
|
|
@@ -1314,7 +1312,7 @@ class WorkOrderSpotCheck extends Api{
|
|
|
|
|
|
if ($allScslEmpty) {
|
|
|
// 当前订单未裁剪 请裁剪后报工
|
|
|
- $this->success($order."\n" .'未裁剪 请裁剪后,在报工', [
|
|
|
+ $this->success('查询失败', [
|
|
|
'code' => 1,
|
|
|
'serial' => '',
|
|
|
'serial_num' => '',
|
|
|
@@ -1924,7 +1922,7 @@ class WorkOrderSpotCheck extends Api{
|
|
|
|
|
|
if ($allScslEmpty) {
|
|
|
// 当前子订单未裁剪 请裁剪后报工
|
|
|
- $this->success($order."\n" .'未裁剪 请裁剪后,在报工', [
|
|
|
+ $this->success('当前子订单未裁剪 请裁剪后报工', [
|
|
|
'code' => 1,
|
|
|
'serial' => '',
|
|
|
'serial_num' => '',
|
|
|
@@ -2871,7 +2869,7 @@ class WorkOrderSpotCheck extends Api{
|
|
|
if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $list = \db('工单_基本资料')->alias('a')
|
|
|
+ $list = \db('工单_基本资料')->alias('a')
|
|
|
->field('
|
|
|
a.订单编号,
|
|
|
a.生产款号,
|
|
|
@@ -2991,11 +2989,12 @@ class WorkOrderSpotCheck extends Api{
|
|
|
Db::startTrans();
|
|
|
|
|
|
try {
|
|
|
- //获取最大批次号
|
|
|
+ //获取最大批次号(兼容 GDGL 前缀)
|
|
|
$lastBatch = Db::name('物料_库存')
|
|
|
->where('批次号', 'like', 'GDGL%')
|
|
|
->orderRaw('CAST(SUBSTRING(批次号, 5) AS UNSIGNED) DESC')
|
|
|
->value('批次号');
|
|
|
+
|
|
|
$currentNumber = $lastBatch ? intval(substr($lastBatch, 4)) : 0;
|
|
|
|
|
|
$insertInventory = []; // 新入库
|
|
|
@@ -3003,40 +3002,36 @@ class WorkOrderSpotCheck extends Api{
|
|
|
$insertLogs = []; // 出入库日志
|
|
|
|
|
|
foreach ($param as $item) {
|
|
|
- if (empty($item['物料编码']) || empty($item['关联编号']) || !isset($item['number'])) {
|
|
|
+ if (empty($item['物料编码']) || empty($item['关联编号']) || !isset($item['number']) || !is_numeric($item['number']) || $item['number'] <= 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // 唯一KEY:物料编码 + 关联号(判断是否已存在)
|
|
|
- $uniqueKey = $item['物料编码'] . '_' . $item['关联编号'];
|
|
|
-
|
|
|
- // 检查是否已存在
|
|
|
- static $exists = [];
|
|
|
- if (!isset($exists[$uniqueKey])) {
|
|
|
- $exists[$uniqueKey] = Db::name('物料_库存')
|
|
|
- ->where('物料编号', $item['物料编码'])
|
|
|
- ->where('关联号', $item['关联编号'])
|
|
|
- ->whereNull('Mod_rq')
|
|
|
- ->value('批次号');
|
|
|
- }
|
|
|
- $existingBatch = $exists[$uniqueKey];
|
|
|
+ // 唯一KEY:物料编码 + 物料名称 + 关联号 + 未删除
|
|
|
+ $existingBatch = Db::name('物料_库存')
|
|
|
+ ->where('物料编号', $item['物料编码'])
|
|
|
+ ->where('物料名称', $item['物料名称'])
|
|
|
+ ->where('关联号', $item['关联编号'])
|
|
|
+ ->whereNull('Mod_rq')
|
|
|
+ ->value('批次号');
|
|
|
|
|
|
if ($existingBatch) {
|
|
|
- //更新
|
|
|
- $updateInventory[] = [
|
|
|
- '批次号' => $existingBatch,
|
|
|
- 'data' => [
|
|
|
- '入仓总量' => Db::raw('入仓总量 + ' . intval($item['number'])),
|
|
|
- '库存数量' => Db::raw('库存数量 + ' . intval($item['number'])),
|
|
|
- '实际门幅' => $item['实际门幅'],
|
|
|
- 'departname' => $item['departname'],
|
|
|
- 'remark' => $item['remark'] ?? '',
|
|
|
- 'sys_rq' => date('Y-m-d H:i:s'),
|
|
|
- ]
|
|
|
+ //更新库存
|
|
|
+ $updateData = [
|
|
|
+ '入仓总量' => Db::raw('入仓总量 + ' . intval($item['number'])),
|
|
|
+ '库存数量' => Db::raw('库存数量 + ' . intval($item['number'])),
|
|
|
+ '实际门幅' => $item['实际门幅'],
|
|
|
+ 'departname' => $item['departname'],
|
|
|
+ 'remark' => $item['remark'] ?? '',
|
|
|
+ 'sys_rq' => date('Y-m-d H:i:s'),
|
|
|
];
|
|
|
+
|
|
|
+ Db::name('物料_库存')
|
|
|
+ ->where('批次号', $existingBatch)
|
|
|
+ ->update($updateData);
|
|
|
+
|
|
|
$BatchNumber = $existingBatch;
|
|
|
} else {
|
|
|
- //新增
|
|
|
+ //新增库存
|
|
|
$currentNumber++;
|
|
|
$BatchNumber = 'GDGL' . $currentNumber;
|
|
|
|
|
|
@@ -3078,21 +3073,14 @@ class WorkOrderSpotCheck extends Api{
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- // 批量新增库存
|
|
|
- if ($insertInventory) {
|
|
|
- Db::name('物料_库存')->insertAll($insertInventory);
|
|
|
- }
|
|
|
-
|
|
|
- // 批量更新库存
|
|
|
- foreach ($updateInventory as $u) {
|
|
|
- Db::name('物料_库存')
|
|
|
- ->where('批次号', $u['批次号'])
|
|
|
- ->update($u['data']);
|
|
|
+ // 批量新增
|
|
|
+ if (!empty($insertInventory)) {
|
|
|
+ Db::name('物料_库存')->fetchSql(true)->insert($insertInventory);
|
|
|
}
|
|
|
|
|
|
- // 批量写入日志
|
|
|
- if ($insertLogs) {
|
|
|
- Db::name('库存_出入库明细')->insertAll($insertLogs);
|
|
|
+ // 批量日志
|
|
|
+ if (!empty($insertLogs)) {
|
|
|
+ Db::name('库存_出入库明细')->fetchSql(true)->insert($insertLogs);
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
|
@@ -3394,7 +3382,7 @@ class WorkOrderSpotCheck extends Api{
|
|
|
/**
|
|
|
* 总检日产量汇总
|
|
|
* code:工序名称
|
|
|
- */
|
|
|
+ */
|
|
|
public function DailyProductionReport(){
|
|
|
if ($this->request->isGet() === false) {
|
|
|
$this->error('请求错误');
|