|
|
@@ -1033,14 +1033,6 @@ class Manufacture extends Api
|
|
|
if (!empty($param['date'])) {
|
|
|
// 日期参数的格式处理
|
|
|
$where['a.sys_rq'] = ['like', "%{$param['date']}%"];
|
|
|
-// if (preg_match('/^\d{4}-\d{2}$/', $param['date'])) {
|
|
|
-// $where['a.sys_rq'] = ['like', "{$param['date']}%"];
|
|
|
-// } elseif (preg_match('/^\d{2}-\d{2}$/', $param['date'])) {
|
|
|
-// $monthDay = $param['date'];
|
|
|
-// $where['a.sys_rq'] = ['like', "%-$monthDay%"];
|
|
|
-// } elseif (preg_match('/^\d{2}$/', $param['date'])) {
|
|
|
-// $where['a.sys_rq'] = ['like', "{$currentYear}-{$param['date']}%"];
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
// 订单编号筛选
|
|
|
@@ -1137,125 +1129,8 @@ class Manufacture extends Api
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 月度车间报工汇总-详情数据
|
|
|
- */
|
|
|
-// public function MachineDetail()
|
|
|
-// {
|
|
|
-// if ($this->request->isGet() === false) {$this->error('请求错误');}
|
|
|
-// $param = $this->request->param();
|
|
|
-// if (empty($param)) {$this->error('参数错误');}
|
|
|
-//
|
|
|
-// $where = [];
|
|
|
-//
|
|
|
-// // 获取当前年份
|
|
|
-// $currentYear = date('Y');
|
|
|
-//
|
|
|
-// // 处理日期参数(可选)
|
|
|
-// if (!empty($param['date'])) {
|
|
|
-// // 检查 `date` 的格式是否为 "YYYY-MM"、"MM-DD" 或仅为月份 "MM"
|
|
|
-// if (preg_match('/^\d{4}-\d{2}$/', $param['date'])) {
|
|
|
-// // 如果格式为 "YYYY-MM",查询当月数据
|
|
|
-// $where['a.sys_rq'] = ['like', "{$param['date']}%"];
|
|
|
-// } elseif (preg_match('/^\d{2}-\d{2}$/', $param['date'])) {
|
|
|
-// // 如果格式为 "MM-DD",查询指定的月份和日期
|
|
|
-// $monthDay = $param['date'];
|
|
|
-// $where['a.sys_rq'] = ['like', "%-$monthDay%"];
|
|
|
-// } elseif (preg_match('/^\d{2}$/', $param['date'])) {
|
|
|
-// // 如果格式为 "MM"(仅月份),自动补全为 "YYYY-MM"
|
|
|
-// $where['a.sys_rq'] = ['like', "{$currentYear}-{$param['date']}%"];
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 判断是否传入订单编号参数(可选)
|
|
|
-// if (!empty($param['order'])) {
|
|
|
-// $where['b.订单编号|b.款号|b.子订单编号'] = ['like', '%' . $param['order'] . '%'];
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 处理机台号参数(可选)
|
|
|
-// if (!empty($param['machine'])) {
|
|
|
-// // 判断是否为年-月格式(2025-02)
|
|
|
-// if (preg_match('/^\d{4}-\d{2}$/', $param['machine'])) {
|
|
|
-// // 如果是日期格式,则设为空
|
|
|
-// $where['a.sczl_jtbh'] = '';
|
|
|
-// } else {
|
|
|
-// // 如果不是日期格式,则正常赋值
|
|
|
-// $where['a.sczl_jtbh'] = $param['machine'];
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if($param['machine'] === '裁剪'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'CQ' . '%'];
|
|
|
-// }else if($param['machine'] === '车缝'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'CF' . '%'];
|
|
|
-// }else if($param['machine'] === '手工'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'HD' . '%'];
|
|
|
-// }else if($param['machine'] === '大烫'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'DT' . '%'];
|
|
|
-// }else if($param['machine'] === '总检'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'ZJ' . '%'];
|
|
|
-// }else if($param['machine'] === '包装'){
|
|
|
-// $where['a.sczl_jtbh'] = ['like', '%' . 'BZ' . '%'];
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 查询数据
|
|
|
-// $list = \db('设备_产量计酬')->alias('a')
|
|
|
-// ->join('工单_印件资料 b', 'b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
|
|
|
-// ->join('工单_基本资料 j', 'b.订单编号 = j.订单编号', 'LEFT')
|
|
|
-// ->field('
|
|
|
-// a.工序名称,b.订单编号, b.子订单编号, b.款号, b.颜色, b.船样, a.尺码, b.zdtotal as 制单数, b.颜色备注,
|
|
|
-// a.数量, MIN(a.sys_rq) as 上报时间, a.UniqId,
|
|
|
-// j.客户编号, j.生产款号, j.款式
|
|
|
-// ')
|
|
|
-// ->where($where)
|
|
|
-// ->where('a.mod_rq', null)
|
|
|
-// ->order('a.sys_rq desc, a.UniqId desc')
|
|
|
-// ->group('a.UniqId')
|
|
|
-// ->select();
|
|
|
-//
|
|
|
-// // 提取所有的尺码,并去重
|
|
|
-// $sizeList = array_values(array_unique(array_column($list, '尺码')));
|
|
|
-//
|
|
|
-// // **自定义排序规则**
|
|
|
-// $sizeOrder = ['XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL']; // 定义字母尺码的顺序
|
|
|
-//
|
|
|
-// usort($sizeList, function ($a, $b) use ($sizeOrder) {
|
|
|
-// // 如果是数字,直接比较大小
|
|
|
-// if (is_numeric($a) && is_numeric($b)) {
|
|
|
-// return $a - $b;
|
|
|
-// }
|
|
|
-// // 如果是字母,按 $sizeOrder 的索引排序
|
|
|
-// if (in_array($a, $sizeOrder) && in_array($b, $sizeOrder)) {
|
|
|
-// return array_search($a, $sizeOrder) - array_search($b, $sizeOrder);
|
|
|
-// }
|
|
|
-// // 如果一个是数字,一个是字母,数字排在前面
|
|
|
-// if (is_numeric($a)) return -1;
|
|
|
-// if (is_numeric($b)) return 1;
|
|
|
-//
|
|
|
-// // 如果都不符合,按字典顺序(备用)
|
|
|
-// return strcmp($a, $b);
|
|
|
-// });
|
|
|
-//
|
|
|
-// // 动态将尺码的数量添加到每个订单中,并替换已完成字段
|
|
|
-// foreach ($list as &$item) {
|
|
|
-// $size = $item['尺码'];
|
|
|
-// $item[$size] = $item['数量'];
|
|
|
-// // unset($item['数量']); // 如果不需要保留原字段,可以取消注释
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 返回结果
|
|
|
-// $this->success('请求成功', [
|
|
|
-// 'table' => $list,
|
|
|
-// 'length' => count($list),
|
|
|
-// 'headers' => $sizeList // 返回所有的尺码作为表头
|
|
|
-// ]);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
- * 工单审核
|
|
|
+ * 样衣核批
|
|
|
*/
|
|
|
public function Approval(){
|
|
|
if ($this->request->isPost() === false) {
|
|
|
@@ -1271,7 +1146,6 @@ class Manufacture extends Api
|
|
|
$data = [
|
|
|
'审核日期' => date('Y-m-d H:i:s'),
|
|
|
'审核' => $param['sys_id'],
|
|
|
-// 'gd_statu' => '3-已完工',
|
|
|
];
|
|
|
// 遍历所有Uniqid进行更新
|
|
|
foreach ($uniqids as $uniqid) {
|
|
|
@@ -1519,7 +1393,7 @@ class Manufacture extends Api
|
|
|
|
|
|
// 提取所有设备编号
|
|
|
$machineCodes = array_column($machineList, '设备编号');
|
|
|
-
|
|
|
+
|
|
|
// 将设备列表转换为关联数组,便于快速查找设备编组
|
|
|
$machineMap = [];
|
|
|
foreach ($machineList as $machine) {
|
|
|
@@ -1538,15 +1412,15 @@ class Manufacture extends Api
|
|
|
foreach ($allOrders as $order) {
|
|
|
$machineCode = $order['sczl_jtbh'];
|
|
|
$yearMonth = date('Ym', strtotime($order['sys_rq']));
|
|
|
-
|
|
|
+
|
|
|
if (!isset($machineMonthlyOrders[$machineCode])) {
|
|
|
$machineMonthlyOrders[$machineCode] = [];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!isset($machineMonthlyOrders[$machineCode][$yearMonth])) {
|
|
|
$machineMonthlyOrders[$machineCode][$yearMonth] = [];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 使用数组键自动去重订单编号
|
|
|
$machineMonthlyOrders[$machineCode][$yearMonth][$order['订单编号']] = true;
|
|
|
}
|
|
|
@@ -1555,14 +1429,14 @@ class Manufacture extends Api
|
|
|
$result = [];
|
|
|
foreach ($machineMonthlyOrders as $machineCode => $monthlyOrders) {
|
|
|
$machineGroup = $machineMap[$machineCode];
|
|
|
-
|
|
|
+
|
|
|
foreach ($monthlyOrders as $yearMonth => $orderMap) {
|
|
|
$workOrderCount = count($orderMap); // 自动去重后的订单数量
|
|
|
-
|
|
|
+
|
|
|
if (!isset($result[$yearMonth])) {
|
|
|
$result[$yearMonth] = [];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 使用关联数组键自动去重设备
|
|
|
$deviceKey = $machineCode . '【' . $machineGroup . ' 生产中:' . $workOrderCount . '】';
|
|
|
$result[$yearMonth][$deviceKey] = true;
|
|
|
@@ -1575,7 +1449,7 @@ class Manufacture extends Api
|
|
|
// 按设备编号排序
|
|
|
sort($monthDevices);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 按月份排序,确保最新的月份在前面
|
|
|
krsort($result);
|
|
|
|
|
|
@@ -1591,19 +1465,19 @@ class Manufacture extends Api
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
$search = input('search', '');
|
|
|
-
|
|
|
+
|
|
|
// 只有当没有搜索参数时,才验证machine和date参数
|
|
|
if (empty($search) && (empty($param['machine']) || empty($param['date']))) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$where = [];
|
|
|
-
|
|
|
+
|
|
|
// 添加搜索条件
|
|
|
if (!empty($search)) {
|
|
|
$where['c.订单编号|j.生产款号|j.款式'] = ['like', '%' . $search . '%'];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 查询设备产量计酬与工单基本资料的关联数据
|
|
|
$query = \db('设备_产量计酬')->alias('c')
|
|
|
->join('工单_基本资料 j', 'c.订单编号 = j.订单编号', 'left')
|
|
|
@@ -1611,12 +1485,12 @@ class Manufacture extends Api
|
|
|
->where('j.Mod_rq', null)
|
|
|
->where('c.工序名称', '车缝') // 只统计工序名称为车缝的数据
|
|
|
->where($where);
|
|
|
-
|
|
|
+
|
|
|
// 添加machine条件(如果提供)
|
|
|
if (!empty($param['machine'])) {
|
|
|
$query->where('c.sczl_jtbh', $param['machine']);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 添加日期范围条件(如果提供)
|
|
|
if (!empty($param['date'])) {
|
|
|
// 将传入的 YYYYMM 格式日期转换为 YYYY-MM-01
|
|
|
@@ -1627,7 +1501,7 @@ class Manufacture extends Api
|
|
|
$query->where('c.sczl_rq', '>=', $startDate)
|
|
|
->where('c.sczl_rq', '<=', $endDate);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 执行查询
|
|
|
$list = $query->field('
|
|
|
c.订单编号, c.款号 as 生产款号, j.款式, j.客户编号,
|
|
|
@@ -1640,7 +1514,7 @@ class Manufacture extends Api
|
|
|
')
|
|
|
->group('c.订单编号')
|
|
|
->select();
|
|
|
-
|
|
|
+
|
|
|
$this->success('请求成功', ['table' => $list, 'length' => count($list)]);
|
|
|
}
|
|
|
|