|
@@ -114,70 +114,149 @@ class FinishedProductWarehousing extends Api
|
|
|
* @param string $date 时间
|
|
* @param string $date 时间
|
|
|
* @param string $sys_id 用户
|
|
* @param string $sys_id 用户
|
|
|
*/
|
|
*/
|
|
|
- public function getList()
|
|
|
|
|
- {
|
|
|
|
|
- //get请求
|
|
|
|
|
- if(!$this->request->isGet()){
|
|
|
|
|
- $this->error('请求方式错误');
|
|
|
|
|
- }
|
|
|
|
|
- $req = $this->request->param();
|
|
|
|
|
- if (!isset($req['date'])) $this->error('参数缺失');
|
|
|
|
|
-
|
|
|
|
|
-// if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
|
|
|
|
|
-// if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
|
|
|
|
|
-
|
|
|
|
|
- if(strpos($req['date'],'-')){
|
|
|
|
|
- $where = ['c.Sys_rq'=>['like',$req['date'].'%']];
|
|
|
|
|
- $option = ['Sys_rq'=>['like',$req['date'].'%']];
|
|
|
|
|
- }else{
|
|
|
|
|
- $where = [];
|
|
|
|
|
- $option = [];
|
|
|
|
|
- }
|
|
|
|
|
- if (isset($req['sys_id']) && !empty($req['sys_id'])){
|
|
|
|
|
- $where['c.Sys_id'] = ['LIKE',$req['sys_id'].'%'];
|
|
|
|
|
- $option['Sys_id'] = ['LIKE',$req['sys_id'].'%'];
|
|
|
|
|
- }
|
|
|
|
|
- //客户编号
|
|
|
|
|
- $rows = db('成品入仓')->alias('c')
|
|
|
|
|
- ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称,
|
|
|
|
|
- rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh,
|
|
|
|
|
- c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj,
|
|
|
|
|
- rtrim(c.jjcp_smb) as jjcp_smb, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc,
|
|
|
|
|
- rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称,
|
|
|
|
|
- rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称,
|
|
|
|
|
- rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
|
|
|
|
|
- ->where($where)
|
|
|
|
|
- ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh AND g.行号 = c.jjcp_yjno AND g.Gd_cpdh=c.jjcp_cpdh')
|
|
|
|
|
- ->order('c.UniqId desc')
|
|
|
|
|
|
|
+// public function getList()
|
|
|
|
|
+// {
|
|
|
|
|
+// //get请求
|
|
|
|
|
+// if(!$this->request->isGet()){
|
|
|
|
|
+// $this->error('请求方式错误');
|
|
|
|
|
+// }
|
|
|
|
|
+// $req = $this->request->param();
|
|
|
|
|
+// if (!isset($req['date'])) $this->error('参数缺失');
|
|
|
|
|
+
|
|
|
|
|
+// // if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
|
|
|
|
|
+// // if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
|
|
|
|
|
+
|
|
|
|
|
+// if(strpos($req['date'],'-')){
|
|
|
|
|
+// $where = ['c.Sys_rq'=>['like',$req['date'].'%']];
|
|
|
|
|
+// $option = ['Sys_rq'=>['like',$req['date'].'%']];
|
|
|
|
|
+// }else{
|
|
|
|
|
+// $where = [];
|
|
|
|
|
+// $option = [];
|
|
|
|
|
+// }
|
|
|
|
|
+// if (isset($req['sys_id']) && !empty($req['sys_id'])){
|
|
|
|
|
+// $where['c.Sys_id'] = ['LIKE',$req['sys_id'].'%'];
|
|
|
|
|
+// $option['Sys_id'] = ['LIKE',$req['sys_id'].'%'];
|
|
|
|
|
+// }
|
|
|
|
|
+// //客户编号
|
|
|
|
|
+// $rows = db('成品入仓')->alias('c')
|
|
|
|
|
+// ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称,
|
|
|
|
|
+// rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh,
|
|
|
|
|
+// c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj,
|
|
|
|
|
+// rtrim(c.jjcp_smb) as jjcp_smb, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc,
|
|
|
|
|
+// rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称,
|
|
|
|
|
+// rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称,
|
|
|
|
|
+// rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
|
|
|
|
|
+// ->where($where)
|
|
|
|
|
+// ->join('工单_基本资料 g','g.Gd_gdbh=c.jjcp_gdbh AND g.行号 = c.jjcp_yjno AND g.Gd_cpdh=c.jjcp_cpdh')
|
|
|
|
|
+// ->order('c.UniqId desc')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+// $total = db('成品入仓')->where($option)->count();
|
|
|
|
|
+// foreach ($rows as $key=>$value) {
|
|
|
|
|
+// $row = db('成品入仓')
|
|
|
|
|
+// ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
|
|
|
|
|
+// ->where(['jjcp_gdbh'=>$value['jjcp_gdbh'], 'jjcp_cpdh'=>$value['jjcp_cpdh']])
|
|
|
|
|
+// ->order('Sys_rq desc')
|
|
|
|
|
+// ->select();
|
|
|
|
|
+// $rows[$key]['jjcp_sls'] = 0;
|
|
|
|
|
+// foreach ($row as $k=>$v) {
|
|
|
|
|
+// $rows[$key]['jjcp_sls'] += $v['jjcp_sl'];
|
|
|
|
|
+// }
|
|
|
|
|
+// if ($value['订单数量']!=0){
|
|
|
|
|
+// $rows[$key]['完成率'] = number_format($rows[$key]['jjcp_sls']/$value['订单数量']/100,2);
|
|
|
|
|
+// }else{
|
|
|
|
|
+// $rows[$key]['完成率'] = '';
|
|
|
|
|
+// }
|
|
|
|
|
+// $rows[$key]['订单数量'] = floatval($value['订单数量']*10000);
|
|
|
|
|
+// $rows[$key]['最近入仓日期'] = $row[0]['Sys_rq'];
|
|
|
|
|
+
|
|
|
|
|
+// $rows[$key]['Mod_rq'] = $value['Mod_rq']=='1900-01-01 00:00:00' ? '' :$value['Mod_rq'];
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// $data = [
|
|
|
|
|
+// 'total' => $total,
|
|
|
|
|
+// 'rows' => $rows,
|
|
|
|
|
+// ];
|
|
|
|
|
+// $this->success('成功',$data);
|
|
|
|
|
+// }
|
|
|
|
|
+public function getList()
|
|
|
|
|
+{
|
|
|
|
|
+ // 验证请求方式
|
|
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
|
|
+ $this->error('请求方式错误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $req = $this->request->param();
|
|
|
|
|
+ if (!isset($req['date'])) {
|
|
|
|
|
+ $this->error('参数缺失');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置分页参数,默认值
|
|
|
|
|
+ $page = isset($req['page']) && !empty($req['page']) ? intval($req['page']) : 1;
|
|
|
|
|
+ $limit = isset($req['limit']) && !empty($req['limit']) ? intval($req['limit']) : 20;
|
|
|
|
|
+
|
|
|
|
|
+ // 构建查询条件
|
|
|
|
|
+ if (strpos($req['date'], '-')) {
|
|
|
|
|
+ $where = ['c.Sys_rq' => ['like', $req['date'] . '%']];
|
|
|
|
|
+ $option = ['Sys_rq' => ['like', $req['date'] . '%']];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $where = [];
|
|
|
|
|
+ $option = [];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isset($req['sys_id']) && !empty($req['sys_id'])) {
|
|
|
|
|
+ $where['c.Sys_id'] = ['LIKE', $req['sys_id'] . '%'];
|
|
|
|
|
+ $option['Sys_id'] = ['LIKE', $req['sys_id'] . '%'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取总数
|
|
|
|
|
+ $total = db('成品入仓')->where($option)->count();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询数据(带分页)
|
|
|
|
|
+ $rows = db('成品入仓')->alias('c')
|
|
|
|
|
+ ->field('rtrim(c.入仓类型) as 入仓类型, rtrim(c.仓库编号) as 仓库编号, rtrim(c.仓库名称) as 仓库名称,
|
|
|
|
|
+ rtrim(c.jjcp_num) as jjcp_num, c.jjcp_gdbh,
|
|
|
|
|
+ c.jjcp_yjno, c.jjcp_sl, g.订单数量, rtrim(c.jjcp_dw) as jjcp_dw, LEFT(c.jjcp_sj, 10) as jjcp_sj,
|
|
|
|
|
+ rtrim(c.jjcp_smb) as jjcp_smb, rtrim(c.jjcp_cpdh) as jjcp_cpdh, rtrim(c.jjcp_cpmc) as jjcp_cpmc,
|
|
|
|
|
+ rtrim(c.成品编码) as 成品编码, rtrim(c.成品名称) as 成品名称,
|
|
|
|
|
+ rtrim(c.客户料号) as 客户料号, rtrim(c.jjcp_desc) as jjcp_desc, LEFT(c.成品编码,'.config('product_code_digit').') as 客户编号, rtrim(g.Gd_客户名称) as Gd_客户名称,
|
|
|
|
|
+ rtrim(c.机型备注) as 机型备注, rtrim(c.Sys_id) as Sys_id, c.Sys_rq, c.Mod_rq, c.UniqId')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->join('工单_基本资料 g', 'g.Gd_gdbh=c.jjcp_gdbh AND g.行号 = c.jjcp_yjno AND g.Gd_cpdh=c.jjcp_cpdh')
|
|
|
|
|
+ ->order('c.UniqId desc')
|
|
|
|
|
+ ->limit(($page - 1) * $limit, $limit)
|
|
|
|
|
+ ->select();
|
|
|
|
|
+
|
|
|
|
|
+ // 处理数据
|
|
|
|
|
+ foreach ($rows as $key => $value) {
|
|
|
|
|
+ $row = db('成品入仓')
|
|
|
|
|
+ ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
|
|
|
|
|
+ ->where(['jjcp_gdbh' => $value['jjcp_gdbh'], 'jjcp_cpdh' => $value['jjcp_cpdh']])
|
|
|
|
|
+ ->order('Sys_rq desc')
|
|
|
->select();
|
|
->select();
|
|
|
- $total = db('成品入仓')->where($option)->count();
|
|
|
|
|
- foreach ($rows as $key=>$value) {
|
|
|
|
|
- $row = db('成品入仓')
|
|
|
|
|
- ->field('LEFT(Sys_rq, 10) as Sys_rq,jjcp_sl')
|
|
|
|
|
- ->where(['jjcp_gdbh'=>$value['jjcp_gdbh'], 'jjcp_cpdh'=>$value['jjcp_cpdh']])
|
|
|
|
|
- ->order('Sys_rq desc')
|
|
|
|
|
- ->select();
|
|
|
|
|
- $rows[$key]['jjcp_sls'] = 0;
|
|
|
|
|
- foreach ($row as $k=>$v) {
|
|
|
|
|
- $rows[$key]['jjcp_sls'] += $v['jjcp_sl'];
|
|
|
|
|
- }
|
|
|
|
|
- if ($value['订单数量']!=0){
|
|
|
|
|
- $rows[$key]['完成率'] = number_format($rows[$key]['jjcp_sls']/$value['订单数量']/100,2);
|
|
|
|
|
- }else{
|
|
|
|
|
- $rows[$key]['完成率'] = '';
|
|
|
|
|
- }
|
|
|
|
|
- $rows[$key]['订单数量'] = floatval($value['订单数量']*10000);
|
|
|
|
|
- $rows[$key]['最近入仓日期'] = $row[0]['Sys_rq'];
|
|
|
|
|
-
|
|
|
|
|
- $rows[$key]['Mod_rq'] = $value['Mod_rq']=='1900-01-01 00:00:00' ? '' :$value['Mod_rq'];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $data = [
|
|
|
|
|
- 'total' => $total,
|
|
|
|
|
- 'rows' => $rows,
|
|
|
|
|
- ];
|
|
|
|
|
- $this->success('成功',$data);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $rows[$key]['jjcp_sls'] = 0;
|
|
|
|
|
+ foreach ($row as $k => $v) {
|
|
|
|
|
+ $rows[$key]['jjcp_sls'] += $v['jjcp_sl'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($value['订单数量'] != 0) {
|
|
|
|
|
+ $rows[$key]['完成率'] = number_format($rows[$key]['jjcp_sls'] / $value['订单数量'] / 100, 2);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $rows[$key]['完成率'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $rows[$key]['订单数量'] = floatval($value['订单数量'] * 10000);
|
|
|
|
|
+ $rows[$key]['最近入仓日期'] = $row[0]['Sys_rq'];
|
|
|
|
|
+ $rows[$key]['Mod_rq'] = $value['Mod_rq'] == '1900-01-01 00:00:00' ? '' : $value['Mod_rq'];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ 'total' => $total,
|
|
|
|
|
+ 'rows' => $rows,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ $this->success('成功', $data);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 定位
|
|
* 定位
|