|
@@ -35,28 +35,40 @@ class WorkOrder extends Api
|
|
|
'productingAll' => $productingAll,
|
|
'productingAll' => $productingAll,
|
|
|
'progressAll' => $progressAll
|
|
'progressAll' => $progressAll
|
|
|
];
|
|
];
|
|
|
- $sql = "SELECT
|
|
|
|
|
- SUBSTRING( `成品代号`, 1, 4 ) AS prefix,
|
|
|
|
|
- rtrim( Gd_khmc ) AS khmc,
|
|
|
|
|
- RTRIM( `Gd_客户名称` ) AS 客户名称
|
|
|
|
|
|
|
+// $sql = "SELECT
|
|
|
|
|
+// SUBSTRING( `成品代号`, 1, 4 ) AS prefix,
|
|
|
|
|
+// rtrim( Gd_khmc ) AS khmc,
|
|
|
|
|
+// RTRIM( `Gd_客户名称` ) AS 客户名称
|
|
|
|
|
+// FROM
|
|
|
|
|
+// `工单_基本资料`
|
|
|
|
|
+// WHERE
|
|
|
|
|
+// `成品代号` <> ''
|
|
|
|
|
+// AND ( `Gd_客户名称` <> '' OR Gd_khmc <> '' )
|
|
|
|
|
+// GROUP BY
|
|
|
|
|
+// prefix
|
|
|
|
|
+// ORDER BY
|
|
|
|
|
+// prefix";
|
|
|
|
|
+ $sql = "SELECT DISTINCT
|
|
|
|
|
+ (客户编号),rtrim(客户名称 ) as 客户名称
|
|
|
FROM
|
|
FROM
|
|
|
- `工单_基本资料`
|
|
|
|
|
- WHERE
|
|
|
|
|
- `成品代号` <> ''
|
|
|
|
|
- AND ( `Gd_客户名称` <> '' OR Gd_khmc <> '' )
|
|
|
|
|
|
|
+ `产品_基本资料`
|
|
|
GROUP BY
|
|
GROUP BY
|
|
|
- prefix
|
|
|
|
|
- ORDER BY
|
|
|
|
|
- prefix";
|
|
|
|
|
|
|
+ 客户编号
|
|
|
|
|
+ order by
|
|
|
|
|
+ 客户编号";
|
|
|
$list = \db()->query($sql);
|
|
$list = \db()->query($sql);
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
$this->success('',[]);
|
|
$this->success('',[]);
|
|
|
}
|
|
}
|
|
|
foreach ($list as $key=>$value){
|
|
foreach ($list as $key=>$value){
|
|
|
|
|
+ $value['客户编号'] = rtrim($value['客户编号']);
|
|
|
|
|
+ if ($value['客户编号'] == '1098'){
|
|
|
|
|
+ $value['客户名称'] = '打样专用';
|
|
|
|
|
+ }
|
|
|
//这条sql查出来的数据可能不对,试一下以下sql
|
|
//这条sql查出来的数据可能不对,试一下以下sql
|
|
|
//SELECT COUNT(*) FROM `工单_基本资料` WHERE (SUBSTRING( `成品代号`, 1, 4 ) = '1001' OR (`Gd_客户名称`='浙江中烟' AND `Gd_客户代号` = '1001')) AND gd_statu = '2-生产中' AND `行号` = '1'
|
|
//SELECT COUNT(*) FROM `工单_基本资料` WHERE (SUBSTRING( `成品代号`, 1, 4 ) = '1001' OR (`Gd_客户名称`='浙江中烟' AND `Gd_客户代号` = '1001')) AND gd_statu = '2-生产中' AND `行号` = '1'
|
|
|
- $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','2-生产中')->count();
|
|
|
|
|
- $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','3-计划中')->count();
|
|
|
|
|
|
|
+ $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
|
|
|
|
|
+ $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
|
|
|
$string = '';
|
|
$string = '';
|
|
|
if ($productIng != 0){
|
|
if ($productIng != 0){
|
|
|
$string = $string."生产中:".$productIng;
|
|
$string = $string."生产中:".$productIng;
|
|
@@ -65,9 +77,11 @@ class WorkOrder extends Api
|
|
|
$string = $string."计划中:".$proGress;
|
|
$string = $string."计划中:".$proGress;
|
|
|
}
|
|
}
|
|
|
if ($string !== ''){
|
|
if ($string !== ''){
|
|
|
- $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
|
|
|
|
+// $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
|
|
+ $data[$key] = $value['客户编号'].'【'.$string.'】'.$value['客户名称'];
|
|
|
}else{
|
|
}else{
|
|
|
- $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
|
|
|
|
+// $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
|
|
+ $data[$key] = $value['客户编号'].$value['客户名称'];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$data);
|
|
$this->success('成功',$data);
|
|
@@ -550,7 +564,7 @@ class WorkOrder extends Api
|
|
|
}
|
|
}
|
|
|
$filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
$filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
|
|
rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
|
|
|
- rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
|
|
|
|
|
|
|
+ rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间,rtrim(UniqId) as UniqId';
|
|
|
$process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
|
|
$process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
|
|
|
if (empty($process)){
|
|
if (empty($process)){
|
|
|
$this->error('未找到该工单工艺资料');
|
|
$this->error('未找到该工单工艺资料');
|
|
@@ -586,7 +600,7 @@ class WorkOrder extends Api
|
|
|
if (empty($productCode) || empty($workOrder)){
|
|
if (empty($productCode) || empty($workOrder)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- $list = \db('工单_基本资料')->where('成品代号',$productCode)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
|
|
|
|
|
|
|
+ $list = \db('工单_基本资料')->where('成品代号',$productCode)->distinct(true)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
$this->success('未获取该产品其他工单信息');
|
|
$this->success('未获取该产品其他工单信息');
|
|
|
}
|
|
}
|
|
@@ -611,32 +625,12 @@ class WorkOrder extends Api
|
|
|
if (Request::instance()->isPost() === false){
|
|
if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
- $oldWorkOrder = input('oldWorkOrder');
|
|
|
|
|
- $newWorkOrder = input('newWorkOrder');
|
|
|
|
|
- if (empty($oldWorkOrder) || empty($newWorkOrder))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
|
|
+ if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- //获取原工单工艺资料
|
|
|
|
|
- $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
|
|
|
|
|
- $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
|
|
|
|
|
- foreach ($oldProcessData as $k=>$v){
|
|
|
|
|
- $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
|
|
|
|
|
- $oldProcessData[$k]['Sys_id'] = '';
|
|
|
|
|
- $oldProcessData[$k]['Mod_rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
- $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (\db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
|
|
|
|
|
- \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
|
|
|
|
|
- }
|
|
|
|
|
- //插入工艺资料
|
|
|
|
|
- $ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
|
|
|
|
|
- $ProcessRes = Db::query($ProcessSQL);
|
|
|
|
|
- if ($ProcessRes !== false){
|
|
|
|
|
- $this->success('成功');
|
|
|
|
|
- }else{
|
|
|
|
|
- $this->error('失败');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1203,4 +1197,79 @@ class WorkOrder extends Api
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$number['小时产能']);
|
|
$this->success('成功',$number['小时产能']);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //新增工单
|
|
|
|
|
+
|
|
|
|
|
+ public function WorkOrderAdd()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增工单->客户代号列表获取
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function ClientList()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql = "SELECT DISTINCT
|
|
|
|
|
+ (客户编号),rtrim(客户名称 ) as 客户名称
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `产品_基本资料`
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ 客户编号
|
|
|
|
|
+ order by
|
|
|
|
|
+ 客户编号";
|
|
|
|
|
+ $list = \db()->query($sql);
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->success('未找到客户列表');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ $list[$key]['客户编号'] = rtrim($value['客户编号']);
|
|
|
|
|
+ if ($value['客户编号'] == '1098'){
|
|
|
|
|
+ $list[$key]['客户名称'] = '打样专用';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增工单->产品代号获取
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param void
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function ProductCodeList()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = \db('产品_基本资料')
|
|
|
|
|
+ ->where('客户编号',$param['cilent'])
|
|
|
|
|
+ ->field('rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->success('未获取到产品数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|