|
@@ -107,44 +107,46 @@ class WorkOrder extends Api
|
|
|
*/
|
|
*/
|
|
|
public function WorkOrderList()
|
|
public function WorkOrderList()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isGet() === false){
|
|
|
|
|
|
|
+ if ($this->request->isGet() === false) {
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
$search = input('search');
|
|
$search = input('search');
|
|
|
- //页数
|
|
|
|
|
$page = input('page');
|
|
$page = input('page');
|
|
|
- //条数
|
|
|
|
|
$limit = input('limit');
|
|
$limit = input('limit');
|
|
|
$param = $this->request->param();
|
|
$param = $this->request->param();
|
|
|
|
|
+
|
|
|
$where = [];
|
|
$where = [];
|
|
|
- if (!empty($search)){
|
|
|
|
|
- $where['订单编号|生产款号|客户编号|款式|审核|Sys_id'] = ['like','%'.$search.'%'];
|
|
|
|
|
|
|
+ if (!empty($search)) {
|
|
|
|
|
+ $where['订单编号|生产款号|客户编号|款式|审核|Sys_id'] = ['like', '%' . $search . '%'];
|
|
|
}
|
|
}
|
|
|
$where['Mod_rq'] = null;
|
|
$where['Mod_rq'] = null;
|
|
|
-// $total = \db('工单_基本资料')->where($where)->distinct(true)->count();
|
|
|
|
|
-// $list = \db('工单_基本资料')
|
|
|
|
|
-// ->where($where)
|
|
|
|
|
-// ->order('订单编号 desc,Gd_statu desc,Sys_rq desc')
|
|
|
|
|
-// ->limit(($page-1)*$limit,$limit)
|
|
|
|
|
-// // ->limit($page,$limit)
|
|
|
|
|
-// ->select();
|
|
|
|
|
- $total = \db('工单_基本资料')->where($where)->distinct(true)->count();
|
|
|
|
|
|
|
+
|
|
|
$list = \db('工单_基本资料')
|
|
$list = \db('工单_基本资料')
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->order('订单编号 desc,Gd_statu desc,Sys_rq desc')
|
|
|
|
|
- ->limit(($page-1)*$limit,$limit)
|
|
|
|
|
|
|
+ ->order('订单编号 desc, Gd_statu desc, Sys_rq desc')
|
|
|
|
|
+ ->limit(($page - 1) * $limit, $limit)
|
|
|
->select();
|
|
->select();
|
|
|
|
|
|
|
|
- foreach ($list as $key=>$value){
|
|
|
|
|
- $number = \db('工单_工艺资料')->where('订单编号',$value['订单编号'])->count();
|
|
|
|
|
- if ($number === 0){
|
|
|
|
|
- $list[$key]['status'] = '*';
|
|
|
|
|
- }else{
|
|
|
|
|
- $list[$key]['status'] = '';
|
|
|
|
|
|
|
+ // 提取所有订单编号
|
|
|
|
|
+ $orderIds = array_column($list, '订单编号');
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有在“工单_相关附件”表中存在的订单编号
|
|
|
|
|
+ $relatedOrders = \db('工单_相关附件')
|
|
|
|
|
+ ->whereIn('关联编号', $orderIds)
|
|
|
|
|
+ ->whereIn('附件备注', '技术附件')
|
|
|
|
|
+ ->column('关联编号');
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历数据,判断每个订单编号是否在相关附件表中
|
|
|
|
|
+ foreach ($list as &$value) {
|
|
|
|
|
+ if (in_array($value['订单编号'], $relatedOrders)) {
|
|
|
|
|
+ $value['status'] = ''; // 有相关附件,status为空
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $value['status'] = '*'; // 没有相关附件,标记为新订单
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-// $this->success('成功',['data'=>$list,'total'=>$total]);
|
|
|
|
|
- $this->success('成功',['data'=>$list,'total'=>count($list)]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $this->success('成功', ['data' => $list, 'total' => count($list)]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -326,7 +328,7 @@ class WorkOrder extends Api
|
|
|
$data = \db('工单_基本资料')->alias('j')
|
|
$data = \db('工单_基本资料')->alias('j')
|
|
|
->field('j.客户编号, REPLACE(DATE_FORMAT(j.Sys_rq, "%Y-%m"), "-", "") as 年月, GROUP_CONCAT(DISTINCT j.订单编号) as 订单编号')
|
|
->field('j.客户编号, REPLACE(DATE_FORMAT(j.Sys_rq, "%Y-%m"), "-", "") as 年月, GROUP_CONCAT(DISTINCT j.订单编号) as 订单编号')
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->order('j.Sys_rq desc')
|
|
|
|
|
|
|
+ ->order('j.客户编号 asc')
|
|
|
->group('j.客户编号, 年月')
|
|
->group('j.客户编号, 年月')
|
|
|
->select();
|
|
->select();
|
|
|
$result = [];
|
|
$result = [];
|
|
@@ -1530,7 +1532,7 @@ class WorkOrder extends Api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 自定义型号排序
|
|
// 自定义型号排序
|
|
|
- $customOrder = array('XS','S', 'M', 'L', 'XL', '2XL', '3XL', '4XL');
|
|
|
|
|
|
|
+ $customOrder = array('XS','S', 'M', 'L', 'XL','XXL', '2XL', '3XL', '4XL');
|
|
|
usort($arr, function ($a, $b) use ($customOrder) {
|
|
usort($arr, function ($a, $b) use ($customOrder) {
|
|
|
$posA = array_search($a, $customOrder);
|
|
$posA = array_search($a, $customOrder);
|
|
|
$posB = array_search($b, $customOrder);
|
|
$posB = array_search($b, $customOrder);
|
|
@@ -1578,60 +1580,55 @@ class WorkOrder extends Api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 工单资料管理->工艺资料删除
|
|
|
|
|
- * @return void
|
|
|
|
|
- * @throws \think\Exception
|
|
|
|
|
- * @throws \think\exception\PDOException
|
|
|
|
|
|
|
+ * 月度车间报工汇总->报工删除记录
|
|
|
*/
|
|
*/
|
|
|
-// public function ProcessDetailDel()
|
|
|
|
|
-// {
|
|
|
|
|
-// if ($this->request->isGet() === false){
|
|
|
|
|
-// $this->error('请求错误');
|
|
|
|
|
-// }
|
|
|
|
|
-// $param = $this->request->param();
|
|
|
|
|
-// if (isset($param['UniqId']) === false){
|
|
|
|
|
-// $this->error('参数错误');
|
|
|
|
|
-// }
|
|
|
|
|
-// $printId = explode(',',$param['UniqId']);
|
|
|
|
|
-// $i = 0;
|
|
|
|
|
-// //获取工单编号、印件号
|
|
|
|
|
-// $codeList = \db('工单_工艺资料')
|
|
|
|
|
-// ->where('UniqId',$printId[0])
|
|
|
|
|
-// ->field('rtrim(Gy0_gdbh) as 工单编号,rtrim(Gy0_yjno) as 印件号')
|
|
|
|
|
-// ->find();
|
|
|
|
|
-// //获取平张投料数量
|
|
|
|
|
-// $number = \db('工单_印件资料')
|
|
|
|
|
-// ->where([
|
|
|
|
|
-// 'Yj_Gdbh' => $codeList['工单编号'],
|
|
|
|
|
-// 'yj_Yjno' => $codeList['印件号']
|
|
|
|
|
-// ])
|
|
|
|
|
-// ->value('rtrim(yj_平张投料)');
|
|
|
|
|
-// //循环删除工艺资料
|
|
|
|
|
-// foreach ($printId as $value){
|
|
|
|
|
-// $res = \db('工单_工艺资料')
|
|
|
|
|
-// ->where('UniqId',$value)
|
|
|
|
|
-// ->delete();
|
|
|
|
|
-// if ($res === false){
|
|
|
|
|
-// $i++;
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// //重新分配工艺计划产量
|
|
|
|
|
-// if ((int)$number>0){
|
|
|
|
|
-// $this->PlannedProcessYield($codeList['工单编号'],$codeList['印件号'],0,$number);
|
|
|
|
|
-// }
|
|
|
|
|
-// if ($i === 0){
|
|
|
|
|
-// $this->success('删除成功');
|
|
|
|
|
-// }else{
|
|
|
|
|
-// $this->error('删除失败');
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ public function ProcessDetailDel()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+// $where['mod_rq'] = ['neq', ''];
|
|
|
|
|
+// $list = \db('设备_产量计酬')->alias('c')
|
|
|
|
|
+// ->field('c.订单编号,j.客户编号,c.mod_rq,c.delsys_id,c.款号,j.款式,,,,,,,,')
|
|
|
|
|
+// ->join('工单_基本资料 j', 'c.订单编号 = j.订单编号', 'left')
|
|
|
|
|
+// ->where($where)
|
|
|
|
|
+// ->order('c.mod_rq desc')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+// echo "<pre>";
|
|
|
|
|
+// print_r($list);
|
|
|
|
|
+// echo "<pre>";
|
|
|
|
|
+
|
|
|
|
|
+ $where['a.mod_rq'] = ['neq', ''];
|
|
|
|
|
+ $list = \db('设备_产量计酬')->alias('a')
|
|
|
|
|
+ ->join('工单_印件资料 b', 'b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
|
|
|
|
|
+ ->join('工单_基本资料 j', 'b.订单编号 = j.订单编号', 'LEFT')
|
|
|
|
|
+ ->field('
|
|
|
|
|
+ b.订单编号, b.子订单编号, b.款号, b.颜色, b.船样, a.尺码, b.zdtotal as 制单数,b.颜色备注,
|
|
|
|
|
+ a.数量, a.sys_rq as 上报时间,a.UniqId,a.mod_rq,a.delsys_id,a.sczl_bh,
|
|
|
|
|
+ j.客户编号,j.生产款号,j.款式
|
|
|
|
|
+ ')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->order('a.mod_rq desc')
|
|
|
|
|
+ ->group('a.UniqId')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+
|
|
|
|
|
+ // 提取所有的尺码,并去重
|
|
|
|
|
+ $sizeList = array_values(array_unique(array_column($list, '尺码')));
|
|
|
|
|
+
|
|
|
|
|
+ // 动态将尺码的数量添加到每个订单中,并替换已完成字段
|
|
|
|
|
+ foreach ($list as &$item) {
|
|
|
|
|
+ $size = $item['尺码'];
|
|
|
|
|
+ $item[$size] = $item['数量']; // 动态添加尺码字段,值为数量
|
|
|
|
|
+// unset($item['数量']); // 移除原来的已完成字段
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $data['total'] = count($list);
|
|
|
|
|
+ $data['table'] = $list;
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 工艺资料添加->工序损耗代码
|
|
* 工艺资料添加->工序损耗代码
|
|
|
- * @return void
|
|
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
- * @throws \think\exception\DbException
|
|
|
|
|
*/
|
|
*/
|
|
|
// public function WastageList()
|
|
// public function WastageList()
|
|
|
// {
|
|
// {
|
|
@@ -2326,77 +2323,160 @@ class WorkOrder extends Api
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
- public function orderPrint()
|
|
|
|
|
- {
|
|
|
|
|
- if ($this->request->isGet() === false){
|
|
|
|
|
- $this->error('请求错误');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public function orderPrint(){
|
|
|
|
|
+ if ($this->request->isGet() === false){$this->error('请求错误');}
|
|
|
$param = $this->request->param();
|
|
$param = $this->request->param();
|
|
|
- if (empty($param['order'])){
|
|
|
|
|
- $this->error('参数错误');
|
|
|
|
|
|
|
+ if (empty($param['order'])){$this->error('参数错误');}
|
|
|
|
|
+
|
|
|
|
|
+ //订单信息
|
|
|
|
|
+ $list = \db('工单_基本资料')
|
|
|
|
|
+ ->where('订单编号',$param['order'])
|
|
|
|
|
+ ->where('Mod_rq',null)
|
|
|
|
|
+ ->field('订单编号,img,生产款号,客户编号,款式,落货日期,箱唛要求,面料,船样描述,船样合计,粘衬,订单数量,审核,审核日期,要求')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+
|
|
|
|
|
+ //表格表头
|
|
|
|
|
+ $xhdata = \db('工单_印件资料')
|
|
|
|
|
+ ->where('订单编号',$param['order'])
|
|
|
|
|
+ ->where('Mod_rq',null)
|
|
|
|
|
+ ->field('cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ $arr = [];
|
|
|
|
|
+ foreach ($xhdata as $key => $value){
|
|
|
|
|
+ for($i=1;$i<=10;$i++){
|
|
|
|
|
+ if ($value['cm'.$i] !== '' && $value['cm'.$i] !== null){
|
|
|
|
|
+ array_push($arr,$value['cm'.$i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ $arr = array_unique($arr);
|
|
|
|
|
|
|
|
- $wheres['Mod_rq'] = null;
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $where['Mod_rq'] = null;
|
|
|
$porlis = \db('工单_印件资料')
|
|
$porlis = \db('工单_印件资料')
|
|
|
->where('订单编号',$param['order'])
|
|
->where('订单编号',$param['order'])
|
|
|
->where('船样',0)
|
|
->where('船样',0)
|
|
|
- ->where($wheres)
|
|
|
|
|
|
|
+ ->where($where)
|
|
|
->field('子订单编号')
|
|
->field('子订单编号')
|
|
|
->select();
|
|
->select();
|
|
|
-
|
|
|
|
|
$subOrder = $porlis[0]['子订单编号'];
|
|
$subOrder = $porlis[0]['子订单编号'];
|
|
|
// 找到子订单编号中的 '-' 位置
|
|
// 找到子订单编号中的 '-' 位置
|
|
|
$dashPos = strpos($subOrder, '-');
|
|
$dashPos = strpos($subOrder, '-');
|
|
|
|
|
+
|
|
|
if ($dashPos !== false) {
|
|
if ($dashPos !== false) {
|
|
|
// 提取 '-' 后面的部分
|
|
// 提取 '-' 后面的部分
|
|
|
$afterDash = substr($subOrder, $dashPos + 1);
|
|
$afterDash = substr($subOrder, $dashPos + 1);
|
|
|
|
|
+
|
|
|
// 判断长度是否等于2或等于4
|
|
// 判断长度是否等于2或等于4
|
|
|
if (strlen($afterDash) == 2) {
|
|
if (strlen($afterDash) == 2) {
|
|
|
- $where['Mod_rq'] = null;
|
|
|
|
|
- $list = \db('工单_基本资料')
|
|
|
|
|
- ->where('订单编号',$param['order'])
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->field('订单编号,img,生产款号,客户编号,款式,落货日期,箱唛要求,面料,船样描述,船样合计,粘衬,订单数量,审核,审核日期,要求')
|
|
|
|
|
- ->find();
|
|
|
|
|
-
|
|
|
|
|
- //表格表头
|
|
|
|
|
- $xhdata = \db('工单_印件资料')
|
|
|
|
|
- ->where('订单编号',$param['order'])
|
|
|
|
|
- ->where('船样',0)
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->field('cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10')
|
|
|
|
|
- ->select();
|
|
|
|
|
- $arr = [];
|
|
|
|
|
- foreach ($xhdata as $key => $value){
|
|
|
|
|
- for($i=1;$i<=10;$i++){
|
|
|
|
|
- if ($value['cm'.$i] !== '' && $value['cm'.$i] !== null){
|
|
|
|
|
- array_push($arr,$value['cm'.$i]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $arr = array_unique($arr);
|
|
|
|
|
- // 初始打印格式
|
|
|
|
|
|
|
+// // 查询船样为0的数据
|
|
|
|
|
+// $processlist = \db('工单_印件资料')
|
|
|
|
|
+// ->where('订单编号', $param['order'])
|
|
|
|
|
+// ->where($where)
|
|
|
|
|
+// ->where('船样', 0)
|
|
|
|
|
+// ->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
|
|
|
+// cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
+// cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+//
|
|
|
|
|
+// foreach ($processlist as $key => $value) {
|
|
|
|
|
+// // 将尺码和对应的数量从 cm1-cm10 和 cmsl1-cmsl10 转换为动态键值对
|
|
|
|
|
+// for ($i = 1; $i <= 10; $i++) {
|
|
|
|
|
+// if ($value['cm' . $i] !== '' && $value['cm' . $i] !== null) {
|
|
|
|
|
+// $processlist[$key][$value['cm' . $i]] = $value['cmsl' . $i];
|
|
|
|
|
+// }
|
|
|
|
|
+// // 移除���始的 cm 和 cmsl 字段
|
|
|
|
|
+// unset($processlist[$key]['cm' . $i], $processlist[$key]['cmsl' . $i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// // 添加条码字段,值为子订单编号
|
|
|
|
|
+// $processlist[$key]['条码'] = $value['子订单编号'];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//// 用于存储合并后的数据
|
|
|
|
|
+// $mergedData = [];
|
|
|
|
|
+//
|
|
|
|
|
+//// 按颜色备注进行合并
|
|
|
|
|
+// foreach ($processlist as $item) {
|
|
|
|
|
+// $key = $item['颜色备注'];
|
|
|
|
|
+//
|
|
|
|
|
+// if (!isset($mergedData[$key])) {
|
|
|
|
|
+// $mergedData[$key] = $item;
|
|
|
|
|
+// } else {
|
|
|
|
|
+// // 合并尺码对应的数量
|
|
|
|
|
+// foreach ($item as $size => $quantity) {
|
|
|
|
|
+// if (is_numeric($size)) {
|
|
|
|
|
+// if (!isset($mergedData[$key][$size])) {
|
|
|
|
|
+// $mergedData[$key][$size] = 0;
|
|
|
|
|
+// }
|
|
|
|
|
+// $mergedData[$key][$size] += $quantity;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// // 合并 zdtotal
|
|
|
|
|
+// $mergedData[$key]['zdtotal'] += $item['zdtotal'];
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//// 将合并后的数据转换为索引数组
|
|
|
|
|
+// $processlist = array_values($mergedData);
|
|
|
|
|
+//
|
|
|
|
|
+//// 如果有 0 的值,清空为 ''
|
|
|
|
|
+// foreach ($processlist as &$row) {
|
|
|
|
|
+// foreach ($row as $key => $value) {
|
|
|
|
|
+// if ($value === 0) {
|
|
|
|
|
+// $row[$key] = '';
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//// 对数组进行排序
|
|
|
|
|
+// sort($processlist);
|
|
|
|
|
+//
|
|
|
|
|
+//// 自定义排序顺序
|
|
|
|
|
+// $customOrder = ['XXS', 'XS', 'S', 'M', 'L', 'XL', 'XXL'];
|
|
|
|
|
+// usort($processlist, function($a, $b) use ($customOrder) {
|
|
|
|
|
+// $posA = array_search($a, $customOrder);
|
|
|
|
|
+// $posB = array_search($b, $customOrder);
|
|
|
|
|
+// return $posA - $posB;
|
|
|
|
|
+// });
|
|
|
|
|
+//
|
|
|
|
|
+//// 查询船样为1的数据
|
|
|
|
|
+// $chuanyang = \db('工单_印件资料')
|
|
|
|
|
+// ->where('订单编号', $param['order'])
|
|
|
|
|
+// ->where($where)
|
|
|
|
|
+// ->where('船样', 1)
|
|
|
|
|
+// ->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
|
|
|
+// cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
+// cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+//
|
|
|
|
|
+// foreach ($chuanyang as $key => $value) {
|
|
|
|
|
+// // 将尺码和对应的数量从 cm1-cm10 和 cmsl1-cmsl10 转换为动态键值对
|
|
|
|
|
+// for ($i = 1; $i <= 10; $i++) {
|
|
|
|
|
+// if ($value['cm' . $i] !== '' && $value['cm' . $i] !== null) {
|
|
|
|
|
+// $chuanyang[$key][$value['cm' . $i]] = $value['cmsl' . $i];
|
|
|
|
|
+// }
|
|
|
|
|
+// // 移除原始的 cm 和 cmsl 字段
|
|
|
|
|
+// unset($chuanyang[$key]['cm' . $i], $chuanyang[$key]['cmsl' . $i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// // 添加条码字段,值为子订单编号
|
|
|
|
|
+// $chuanyang[$key]['条码'] = $value['子订单编号'];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//// 将船样为1的数据添加到船样为0的数据后面
|
|
|
|
|
+// $finalList = array_merge($processlist, $chuanyang);
|
|
|
|
|
+//
|
|
|
|
|
+// $data['process'] = $finalList;
|
|
|
|
|
+ // 查询船样为0的数据
|
|
|
$processlist = \db('工单_印件资料')
|
|
$processlist = \db('工单_印件资料')
|
|
|
->where('订单编号', $param['order'])
|
|
->where('订单编号', $param['order'])
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->where('船样', 0)
|
|
->where('船样', 0)
|
|
|
->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
|
- cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
- cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
|
|
|
|
+cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
+cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
->select();
|
|
->select();
|
|
|
|
|
|
|
|
- if (!$processlist) {
|
|
|
|
|
- $processlist = \db('工单_印件资料')
|
|
|
|
|
- ->where('订单编号', $param['order'])
|
|
|
|
|
- ->where('船样', 0)
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
|
|
|
- cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
- cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
|
|
- ->select();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
foreach ($processlist as $key => $value) {
|
|
foreach ($processlist as $key => $value) {
|
|
|
// 将尺码和对应的数量从 cm1-cm10 和 cmsl1-cmsl10 转换为动态键值对
|
|
// 将尺码和对应的数量从 cm1-cm10 和 cmsl1-cmsl10 转换为动态键值对
|
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
@@ -2406,148 +2486,208 @@ class WorkOrder extends Api
|
|
|
// 移除原始的 cm 和 cmsl 字段
|
|
// 移除原始的 cm 和 cmsl 字段
|
|
|
unset($processlist[$key]['cm' . $i], $processlist[$key]['cmsl' . $i]);
|
|
unset($processlist[$key]['cm' . $i], $processlist[$key]['cmsl' . $i]);
|
|
|
}
|
|
}
|
|
|
- // 添加条码字段,值为子订单编号
|
|
|
|
|
- $processlist[$key]['条码'] = $value['子订单编号'];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 如果有 0 的值,清空为 ''
|
|
|
|
|
- foreach ($processlist as &$row) {
|
|
|
|
|
- foreach ($row as $key => $value) {
|
|
|
|
|
- if ($value === 0) {
|
|
|
|
|
- $row[$key] = '';
|
|
|
|
|
|
|
+// 用于存储合并后的数据
|
|
|
|
|
+ $mergedData = [];
|
|
|
|
|
+
|
|
|
|
|
+// 按颜色备注进行合并
|
|
|
|
|
+ foreach ($processlist as $item) {
|
|
|
|
|
+ $key = $item['颜色备注'];
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset($mergedData[$key])) {
|
|
|
|
|
+ $mergedData[$key] = $item;
|
|
|
|
|
+ // 添加条码字段,值为子订单编号
|
|
|
|
|
+ $mergedData[$key]['条码'] = $item['子订单编号'];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 合并尺码对应的数量
|
|
|
|
|
+ foreach ($item as $size => $quantity) {
|
|
|
|
|
+ if (is_numeric($size)) {
|
|
|
|
|
+ if (!isset($mergedData[$key][$size])) {
|
|
|
|
|
+ $mergedData[$key][$size] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $mergedData[$key][$size] += $quantity;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ // 合并 zdtotal
|
|
|
|
|
+ $mergedData[$key]['zdtotal'] += $item['zdtotal'];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- sort($arr);
|
|
|
|
|
- $customOrder = ['XXS','XS', 'S', 'M', 'L', 'XL', 'XXL'];
|
|
|
|
|
- usort($arr, function($a, $b) use ($customOrder) {
|
|
|
|
|
- $posA = array_search($a, $customOrder);
|
|
|
|
|
- $posB = array_search($b, $customOrder);
|
|
|
|
|
- return $posA - $posB;
|
|
|
|
|
- });
|
|
|
|
|
- $data['order'] = $list;
|
|
|
|
|
- $data['xhdata'] = $arr;
|
|
|
|
|
- $data['print'] = 1;
|
|
|
|
|
- $data['process'] = $processlist;
|
|
|
|
|
- $this->success('成功',$data);
|
|
|
|
|
- } elseif (strlen($afterDash) == 4) {
|
|
|
|
|
- $where['Mod_rq'] = null;
|
|
|
|
|
- $list = \db('工单_基本资料')
|
|
|
|
|
- ->where('订单编号',$param['order'])
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->field('订单编号,img,生产款号,客户编号,款式,落货日期,箱唛要求,面料,船样描述,船样合计,粘衬,订单数量,审核,审核日期,要求')
|
|
|
|
|
- ->find();
|
|
|
|
|
|
|
|
|
|
- //表格表头
|
|
|
|
|
- $xhdata = \db('工单_印件资料')
|
|
|
|
|
- ->where('订单编号',$param['order'])
|
|
|
|
|
- ->where('船样',0)
|
|
|
|
|
|
|
+// 查询船样为1的数据
|
|
|
|
|
+ $chuanyang = \db('工单_印件资料')
|
|
|
|
|
+ ->where('订单编号', $param['order'])
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->field('cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10')
|
|
|
|
|
|
|
+ ->where('船样', 1)
|
|
|
|
|
+ ->field('子订单编号,颜色,款号,zdtotal,颜色备注,color_id,
|
|
|
|
|
+cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10,
|
|
|
|
|
+cmsl1,cmsl2,cmsl3,cmsl4,cmsl5,cmsl6,cmsl7,cmsl8,cmsl9,cmsl10,Uniqid')
|
|
|
->select();
|
|
->select();
|
|
|
- $arr = [];
|
|
|
|
|
- foreach ($xhdata as $key => $value){
|
|
|
|
|
- for($i=1;$i<=10;$i++){
|
|
|
|
|
- if ($value['cm'.$i] !== '' && $value['cm'.$i] !== null){
|
|
|
|
|
- array_push($arr,$value['cm'.$i]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($chuanyang as $key => $value) {
|
|
|
|
|
+ // 将尺码和对应的数量从 cm1-cm10 和 cmsl1-cmsl10 转换为动态键值对
|
|
|
|
|
+ for ($i = 1; $i <= 10; $i++) {
|
|
|
|
|
+ if ($value['cm' . $i] !== '' && $value['cm' . $i] !== null) {
|
|
|
|
|
+ $chuanyang[$key][$value['cm' . $i]] = $value['cmsl' . $i];
|
|
|
}
|
|
}
|
|
|
|
|
+ // 移除原始的 cm 和 cmsl 字段
|
|
|
|
|
+ unset($chuanyang[$key]['cm' . $i], $chuanyang[$key]['cmsl' . $i]);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 添加条码字段,值为子订单编号
|
|
|
|
|
+ $chuanyang[$key]['条码'] = $value['子订单编号'];
|
|
|
}
|
|
}
|
|
|
- $arr = array_unique($arr);
|
|
|
|
|
|
|
|
|
|
- // 初始数据查询
|
|
|
|
|
|
|
+// 将合并后的数据插入到相应颜色备注的原始数据尾部
|
|
|
|
|
+ $finalList = [];
|
|
|
|
|
+ $groupedData = [];
|
|
|
|
|
+
|
|
|
|
|
+// 将原始数据按颜色备注分组
|
|
|
|
|
+ foreach ($processlist as $item) {
|
|
|
|
|
+ $key = $item['颜色备注'];
|
|
|
|
|
+ if (!isset($groupedData[$key])) {
|
|
|
|
|
+ $groupedData[$key] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $groupedData[$key][] = $item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// 将合并后的数据插入到对应的颜色备注组的尾部
|
|
|
|
|
+ foreach ($groupedData as $key => $items) {
|
|
|
|
|
+ $finalList = array_merge($finalList, $items); // 先添加原始数据
|
|
|
|
|
+ if (isset($mergedData[$key])) {
|
|
|
|
|
+ $finalList[] = $mergedData[$key]; // 在组的尾部添加合并数据
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// 将船样为1的数据添加到最终列表中
|
|
|
|
|
+ $finalList = array_merge($finalList, $chuanyang);
|
|
|
|
|
+
|
|
|
|
|
+// 最终数据结构
|
|
|
|
|
+ $data['process'] = $finalList;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $data['order'] = $list;
|
|
|
|
|
+ $data['xhdata'] = $arr;
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
|
|
+ } elseif (strlen($afterDash) == 4) {
|
|
|
|
|
+ // 获取印件资料
|
|
|
$processlist = \db('工单_印件资料')
|
|
$processlist = \db('工单_印件资料')
|
|
|
->where('订单编号', $param['order'])
|
|
->where('订单编号', $param['order'])
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->where('船样', 0)
|
|
->where('船样', 0)
|
|
|
- ->field('子订单编号, 颜色, 款号, zdtotal, 颜色备注, color_id,
|
|
|
|
|
|
|
+ ->field('子订单编号, 颜色, 款号, zdtotal, 颜色备注, color_id, 船样,
|
|
|
cm1, cm2, cm3, cm4, cm5, cm6, cm7, cm8, cm9, cm10,
|
|
cm1, cm2, cm3, cm4, cm5, cm6, cm7, cm8, cm9, cm10,
|
|
|
cmsl1, cmsl2, cmsl3, cmsl4, cmsl5, cmsl6, cmsl7, cmsl8, cmsl9, cmsl10, Uniqid')
|
|
cmsl1, cmsl2, cmsl3, cmsl4, cmsl5, cmsl6, cmsl7, cmsl8, cmsl9, cmsl10, Uniqid')
|
|
|
->select();
|
|
->select();
|
|
|
|
|
|
|
|
- $mergedList = [];
|
|
|
|
|
- $summaryList = []; // 存储汇总数据
|
|
|
|
|
|
|
+// 保存格式化后的数据
|
|
|
|
|
+ $formattedData = [];
|
|
|
|
|
|
|
|
|
|
+// 遍历数据进行尺码转换并添加到输出数组
|
|
|
foreach ($processlist as $item) {
|
|
foreach ($processlist as $item) {
|
|
|
- $colorId = $item['color_id'];
|
|
|
|
|
- $subOrderPrefix = substr($item['子订单编号'], 0, -2); // 获取子订单编号的前几位
|
|
|
|
|
- $subOrderSuffix = substr($item['子订单编号'], -2); // 获取子订单编号的后两位
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否为汇总项(子订单编号后两位为 "00")
|
|
|
|
|
- if ($subOrderSuffix === '00') {
|
|
|
|
|
- // 初始化汇总数据
|
|
|
|
|
- if (!isset($summaryList[$subOrderPrefix])) {
|
|
|
|
|
- $summaryList[$subOrderPrefix] = [
|
|
|
|
|
- '子订单编号' => $item['子订单编号'],
|
|
|
|
|
- '条码' => $item['子订单编号'], // 条码字段作为汇总项显示
|
|
|
|
|
- '颜色' => $item['颜色'],
|
|
|
|
|
- '款号' => $item['款号'],
|
|
|
|
|
- 'zdtotal' => 0, // 累计总量
|
|
|
|
|
- '颜色备注' => $item['颜色备注'],
|
|
|
|
|
- 'color_id' => $colorId,
|
|
|
|
|
- 'cm1' => $item['cm1'],
|
|
|
|
|
- 'cm2' => $item['cm2'],
|
|
|
|
|
- 'cm3' => $item['cm3'],
|
|
|
|
|
- 'cm4' => $item['cm4'],
|
|
|
|
|
- 'cm5' => $item['cm5'],
|
|
|
|
|
- 'cm6' => $item['cm6'],
|
|
|
|
|
- 'cm7' => $item['cm7'],
|
|
|
|
|
- 'cm8' => $item['cm8'],
|
|
|
|
|
- 'cm9' => $item['cm9'],
|
|
|
|
|
- 'cm10' => $item['cm10'],
|
|
|
|
|
- 'cmsl1' => 0,
|
|
|
|
|
- 'cmsl2' => 0,
|
|
|
|
|
- 'cmsl3' => 0,
|
|
|
|
|
- 'cmsl4' => 0,
|
|
|
|
|
- 'cmsl5' => 0,
|
|
|
|
|
- 'cmsl6' => 0,
|
|
|
|
|
- 'cmsl7' => 0,
|
|
|
|
|
- 'cmsl8' => 0,
|
|
|
|
|
- 'cmsl9' => 0,
|
|
|
|
|
- 'cmsl10' => 0,
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ for ($i = 1; $i <= 10; $i++) {
|
|
|
|
|
+ if (!empty($item['cm' . $i])) {
|
|
|
|
|
+ $item[$item['cm' . $i]] = $item['cmsl' . $i];
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($item['cm' . $i], $item['cmsl' . $i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ $formattedData[] = $item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// 用于存储每个 color_id 和颜色备注的合并数据
|
|
|
|
|
+ $mergedData = [];
|
|
|
|
|
+
|
|
|
|
|
+// 进行合并
|
|
|
|
|
+ foreach ($formattedData as $item) {
|
|
|
|
|
+ $key = $item['color_id'] . '|' . $item['颜色备注'];
|
|
|
|
|
+
|
|
|
|
|
+ if (!isset($mergedData[$key])) {
|
|
|
|
|
+ $mergedData[$key] = $item;
|
|
|
|
|
+ $mergedData[$key]['条码'] = $item['子订单编号']; // 初始化条码
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 合并 zdtotal 和尺码数量
|
|
|
|
|
+ $mergedData[$key]['zdtotal'] += $item['zdtotal'];
|
|
|
|
|
+ foreach (['36', '38', '40', '42', '44', '46', '48'] as $size) {
|
|
|
|
|
+ if (isset($item[$size])) {
|
|
|
|
|
+ $mergedData[$key][$size] = ($mergedData[$key][$size] ?? 0) + $item[$size];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- for ($i = 1; $i <= 10; $i++) {
|
|
|
|
|
- $summaryList[$subOrderPrefix]['cmsl' . $i] += $item['cmsl' . $i];
|
|
|
|
|
|
|
+ // 优先选择以 "00" 结尾的条码
|
|
|
|
|
+ if (substr($item['子订单编号'], -2) == '00') {
|
|
|
|
|
+ $mergedData[$key]['条码'] = $item['子订单编号'];
|
|
|
}
|
|
}
|
|
|
- $summaryList[$subOrderPrefix]['zdtotal'] += $item['zdtotal'];
|
|
|
|
|
}
|
|
}
|
|
|
- // 不论是否为汇总项,原始数据都保留到结果数组中 // 非汇总项的条码为空
|
|
|
|
|
- $item['条码'] = '';
|
|
|
|
|
- $mergedList[] = $item;
|
|
|
|
|
}
|
|
}
|
|
|
- // 将汇总数据追加到结果数组中
|
|
|
|
|
- foreach ($summaryList as $summary) {
|
|
|
|
|
- $mergedList[] = $summary;
|
|
|
|
|
|
|
+
|
|
|
|
|
+// 将合并后的数据添加到原始数据的末尾,并排序
|
|
|
|
|
+ $finalOutput = $formattedData;
|
|
|
|
|
+
|
|
|
|
|
+// 按 color_id 和 颜色备注 分组,并在每组末尾添加合并后的条码数据
|
|
|
|
|
+ foreach ($mergedData as $key => $mergeItem) {
|
|
|
|
|
+ $mergeItem['合并标记'] = true; // 用于标记这是合并后的数据
|
|
|
|
|
+ $finalOutput[] = $mergeItem;
|
|
|
}
|
|
}
|
|
|
- // 处理动态字段和清空 0 值
|
|
|
|
|
- foreach ($mergedList as $key => $value) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+// 对最终数组进行排序
|
|
|
|
|
+ usort($finalOutput, function($a, $b) {
|
|
|
|
|
+ // 先按 color_id 排序
|
|
|
|
|
+ $compare = strcmp($a['color_id'], $b['color_id']);
|
|
|
|
|
+ if ($compare === 0) {
|
|
|
|
|
+ // 在 color_id 相同的情况下,再按 颜色备注 排序
|
|
|
|
|
+ $compare = strcmp($a['颜色备注'], $b['颜色备注']);
|
|
|
|
|
+ if ($compare === 0) {
|
|
|
|
|
+ // 在 颜色备注相同的情况下,按 子订单编号 排序
|
|
|
|
|
+ // 如果一项是合并标记的条码数据,另一项不是,则合并标记的条码数据排在后面
|
|
|
|
|
+ if (isset($a['合并标记']) && !isset($b['合并标记'])) {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ } elseif (!isset($a['合并标记']) && isset($b['合并标记'])) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return strcmp($a['子订单编号'], $b['子订单编号']);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $compare;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $compare;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+// 查询仅获取船样为 1 的数据
|
|
|
|
|
+ $chuanyang = \db('工单_印件资料')
|
|
|
|
|
+ ->where('订单编号', $param['order'])
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->where('船样', 1)
|
|
|
|
|
+ ->field('子订单编号, 颜色, 款号, zdtotal, 颜色备注, color_id, 船样,
|
|
|
|
|
+ cm1, cm2, cm3, cm4, cm5, cm6, cm7, cm8, cm9, cm10,
|
|
|
|
|
+ cmsl1, cmsl2, cmsl3, cmsl4, cmsl5, cmsl6, cmsl7, cmsl8, cmsl9, cmsl10, Uniqid')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+
|
|
|
|
|
+ $chuanyangvval = [];
|
|
|
|
|
+// 遍历船样为 1 的数据,进行尺码转换
|
|
|
|
|
+ foreach ($chuanyang as $item) {
|
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
|
- if ($value['cm' . $i] !== '' && $value['cm' . $i] !== null) {
|
|
|
|
|
- $mergedList[$key][$value['cm' . $i]] = $value['cmsl' . $i];
|
|
|
|
|
|
|
+ if (!empty($item['cm' . $i])) {
|
|
|
|
|
+ $item[$item['cm' . $i]] = $item['cmsl' . $i];
|
|
|
}
|
|
}
|
|
|
- unset($mergedList[$key]['cm' . $i], $mergedList[$key]['cmsl' . $i]);
|
|
|
|
|
|
|
+ unset($item['cm' . $i], $item['cmsl' . $i]);
|
|
|
}
|
|
}
|
|
|
|
|
+ $item['条码'] = $item['子订单编号'];
|
|
|
|
|
+ $chuanyangvval[] = $item;
|
|
|
}
|
|
}
|
|
|
- // 清空 0 值
|
|
|
|
|
- foreach ($mergedList as &$row) {
|
|
|
|
|
- foreach ($row as $key => $value) {
|
|
|
|
|
- if ($value === 0) {
|
|
|
|
|
- $row[$key] = '';
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+// 合并船样和非船样的数据并去重
|
|
|
|
|
+ $final = array_map("unserialize", array_unique(array_map("serialize", array_merge($finalOutput, $chuanyangvval))));
|
|
|
|
|
+
|
|
|
|
|
+// 最后清除带有条码的数据中的子订单编号和颜色信息
|
|
|
|
|
+ foreach ($final as &$item) {
|
|
|
|
|
+ if (isset($item['条码']) && $item['船样'] == 0) {
|
|
|
|
|
+ $item['子订单编号'] = '';
|
|
|
|
|
+ $item['颜色'] = '';
|
|
|
|
|
+ $item['款号'] = '';
|
|
|
|
|
+ unset($item['子订单编号'], $item['颜色']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- sort($arr);
|
|
|
|
|
- $customOrder = ['XXS','XS', 'S', 'M', 'L', 'XL', 'XXL'];
|
|
|
|
|
- usort($arr, function($a, $b) use ($customOrder) {
|
|
|
|
|
- $posA = array_search($a, $customOrder);
|
|
|
|
|
- $posB = array_search($b, $customOrder);
|
|
|
|
|
- return $posA - $posB;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $data['process'] = $final;
|
|
|
$data['order'] = $list;
|
|
$data['order'] = $list;
|
|
|
$data['xhdata'] = $arr;
|
|
$data['xhdata'] = $arr;
|
|
|
- $data['process'] = $mergedList;
|
|
|
|
|
-
|
|
|
|
|
$this->success('成功', $data);
|
|
$this->success('成功', $data);
|
|
|
} else {
|
|
} else {
|
|
|
echo "子订单编号 - 后不是2位也不是4位:$afterDash";
|
|
echo "子订单编号 - 后不是2位也不是4位:$afterDash";
|
|
@@ -3080,10 +3220,12 @@ class WorkOrder extends Api
|
|
|
->field('colorcode, colorname')
|
|
->field('colorcode, colorname')
|
|
|
->where('colorname', $param['colorname'] ?? '')
|
|
->where('colorname', $param['colorname'] ?? '')
|
|
|
->find();
|
|
->find();
|
|
|
|
|
+
|
|
|
if (empty($colorlist)) {
|
|
if (empty($colorlist)) {
|
|
|
$this->error('未找到对应的颜色编号');
|
|
$this->error('未找到对应的颜色编号');
|
|
|
}
|
|
}
|
|
|
$num = $param['order'] . '-' . $colorlist['colorcode'];
|
|
$num = $param['order'] . '-' . $colorlist['colorcode'];
|
|
|
|
|
+
|
|
|
// 查询子订单编号
|
|
// 查询子订单编号
|
|
|
$data = \db('工单_印件资料')
|
|
$data = \db('工单_印件资料')
|
|
|
->field('子订单编号,cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10')
|
|
->field('子订单编号,cm1,cm2,cm3,cm4,cm5,cm6,cm7,cm8,cm9,cm10')
|
|
@@ -3091,27 +3233,48 @@ class WorkOrder extends Api
|
|
|
->where('船样', '=', 0)
|
|
->where('船样', '=', 0)
|
|
|
->order('子订单编号', 'desc')
|
|
->order('子订单编号', 'desc')
|
|
|
->find();
|
|
->find();
|
|
|
|
|
+
|
|
|
if (empty($data)) {
|
|
if (empty($data)) {
|
|
|
// 如果没有找到数据,生成默认的订单编号,后两位从00开始
|
|
// 如果没有找到数据,生成默认的订单编号,后两位从00开始
|
|
|
$order = $param['order'] . '-' . $colorlist['colorcode'] . '00';
|
|
$order = $param['order'] . '-' . $colorlist['colorcode'] . '00';
|
|
|
} else {
|
|
} else {
|
|
|
- // 如果找到数据,提取子订单编号并递增
|
|
|
|
|
- $order = $data['子订单编号'];
|
|
|
|
|
- if (preg_match('/(.*-' . $colorlist['colorcode'] . ')(\d{2})$/', $order, $matches)) {
|
|
|
|
|
- $prefix = $matches[1]; // 前缀部分(包括订单编号和颜色代码)
|
|
|
|
|
- $number = $matches[2]; // 数字部分(后两位)
|
|
|
|
|
-
|
|
|
|
|
- // 循环生成子订单编号并检查数据库中是否存在相同编号
|
|
|
|
|
- do {
|
|
|
|
|
- $incrementedNumber = (int)$number + 1;
|
|
|
|
|
- // 将数字部分补充为两位数,例如 1 -> 01,2 -> 02
|
|
|
|
|
- $order = $prefix . str_pad($incrementedNumber, 2, '0', STR_PAD_LEFT);
|
|
|
|
|
- $exists = \db('工单_印件资料')->where('子订单编号', '=', $order)->find();
|
|
|
|
|
- $number = $incrementedNumber; // 更新 number 用于下一次循环
|
|
|
|
|
- } while ($exists); // 如果存在相同编号则继续循环递增
|
|
|
|
|
- } else {
|
|
|
|
|
- $this->error('订单编号格式错误');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (strlen($data['子订单编号']) == 12) {
|
|
|
|
|
+ $data = \db('工单_印件资料')
|
|
|
|
|
+ ->where('订单编号',$param['order'])
|
|
|
|
|
+ ->where('船样',0)
|
|
|
|
|
+ ->order('子订单编号 desc')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ if(empty($data)){
|
|
|
|
|
+ $order = $param['order'].'-01';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $num = (int)substr($data['子订单编号'],10) + 1;
|
|
|
|
|
+ if ($num<10){
|
|
|
|
|
+ $order = $param['order'].'-0'.$num;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $order = $param['order'].'-'.$num;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 如果找到数据,提取子订单编号并递增
|
|
|
|
|
+ $order = $data['子订单编号'];
|
|
|
|
|
+ if (preg_match('/(.*-' . $colorlist['colorcode'] . ')(\d{2})$/', $order, $matches)) {
|
|
|
|
|
+ $prefix = $matches[1]; // 前缀部分(包括订单编号和颜色代码)
|
|
|
|
|
+ $number = $matches[2]; // 数字部分(后两位)
|
|
|
|
|
+
|
|
|
|
|
+ // 循环生成子订单编号并检查数据库中是否存在相同编号
|
|
|
|
|
+ do {
|
|
|
|
|
+ $incrementedNumber = (int)$number + 1;
|
|
|
|
|
+ // 将数字部分补充为两位数,例如 1 -> 01,2 -> 02
|
|
|
|
|
+ $order = $prefix . str_pad($incrementedNumber, 2, '0', STR_PAD_LEFT);
|
|
|
|
|
+ $exists = \db('工单_印件资料')->where('子订单编号', '=', $order)->find();
|
|
|
|
|
+ $number = $incrementedNumber; // 更新 number 用于下一次循环
|
|
|
|
|
+ } while ($exists); // 如果存在相同编号则继续循环递增
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $this->error('订单编号格式错误');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//2.获取色系名称信息
|
|
//2.获取色系名称信息
|