|
|
@@ -87,9 +87,9 @@ class PackagingCountDocument extends Api
|
|
|
|
|
|
$rows = db()->table('db_包装计件')
|
|
|
->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh,
|
|
|
- CAST(sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 AS SIGNED) as sczl_cl,
|
|
|
- CAST(sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 AS SIGNED) as sczl_fgsl,
|
|
|
- CAST(sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 AS SIGNED) as sczl_jjcl,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl,
|
|
|
+ sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl,
|
|
|
sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
|
|
|
->where($where)
|
|
|
->page($page,$limit)
|
|
|
@@ -97,6 +97,9 @@ class PackagingCountDocument extends Api
|
|
|
$total = db()->table('db_包装计件')->where($where)->count();
|
|
|
$rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
|
|
|
foreach ($rows as $key=>$value) {
|
|
|
+ $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
|
|
|
+ $rows[$key]['sczl_fgsl'] = floatval($value['sczl_fgsl']);
|
|
|
+ $rows[$key]['sczl_jjcl'] = floatval($value['sczl_jjcl']);
|
|
|
$rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
|
|
|
$rows[$key]['name'] = array_key_exists($value['sczl_bh'],$rs) ? trim($rs[$value['sczl_bh']]) : '';
|
|
|
}
|
|
|
@@ -109,7 +112,79 @@ class PackagingCountDocument extends Api
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取包装计件单据信息
|
|
|
+ * 定位
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $gdbh 工单编号
|
|
|
+ * @param string $cpmc 产品名称
|
|
|
+ * @param string $page 页码
|
|
|
+ * @param string $limit 数量
|
|
|
+ */
|
|
|
+ public function locate()
|
|
|
+ {
|
|
|
+ //get请求
|
|
|
+ if(!$this->request->isGet()){
|
|
|
+ $this->error('请求方式错误');
|
|
|
+ }
|
|
|
+ $req = $this->request->param();
|
|
|
+
|
|
|
+ $page = 1;
|
|
|
+ $limit = 15;
|
|
|
+ if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
|
|
|
+ if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
|
|
|
+
|
|
|
+ if (isset($req['gdbh']) && !empty($req['gdbh'])){
|
|
|
+ $where = [
|
|
|
+ 'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>[ 'like', '%' . $req['gdbh'] . '%']
|
|
|
+ ];
|
|
|
+ $rows = db()->table('db_包装计件')
|
|
|
+ ->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl,
|
|
|
+ sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl,
|
|
|
+ sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
|
|
|
+ ->where($where)
|
|
|
+ ->page($page,$limit)
|
|
|
+ ->select();
|
|
|
+ $total = db()->table('db_包装计件')->where($where)->count();
|
|
|
+ }else{
|
|
|
+ if (isset($req['cpmc']) && !empty($req['cpmc'])){
|
|
|
+ //查询工单表
|
|
|
+ $gd = db()->table('工单_基本资料')
|
|
|
+ ->where('Gd_cpmc', 'LIKE', '%'.$req['cpmc'].'%')
|
|
|
+ ->column('Gd_gdbh');
|
|
|
+ $where = [
|
|
|
+ 'sczl_gdbh1|sczl_gdbh2|sczl_gdbh3|sczl_gdbh4|sczl_gdbh5|sczl_gdbh6'=>['in', $gd]
|
|
|
+ ];
|
|
|
+ $rows = db()->table('db_包装计件')
|
|
|
+ ->field('sczl_bh, LEFT(sczl_rq, 10) as sczl_rq, sczl_bzdh,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 as sczl_cl,
|
|
|
+ sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_fgsl,
|
|
|
+ sczl_cl1 + sczl_cl2 + sczl_cl3 + sczl_cl4 + sczl_cl5 + sczl_cl6 + sczl_返工产量1 + sczl_返工产量2 + sczl_返工产量3 + sczl_返工产量4 + sczl_返工产量5 + sczl_返工产量6 as sczl_jjcl,
|
|
|
+ sczl_gdbh1, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
|
|
|
+ ->where($where)
|
|
|
+ ->page($page,$limit)
|
|
|
+ ->select();
|
|
|
+ $total = db()->table('db_包装计件')->where($where)->count();
|
|
|
+ }else{
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($rows as $key=>$value){
|
|
|
+ $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
|
|
|
+ $rows[$key]['sczl_cl'] = floatval($value['sczl_cl']);
|
|
|
+ $rows[$key]['sczl_fgsl'] = floatval($value['sczl_fgsl']);
|
|
|
+ $rows[$key]['sczl_jjcl'] = floatval($value['sczl_jjcl']);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'total' => $total,
|
|
|
+ 'rows' => $rows,
|
|
|
+ ];
|
|
|
+ $this->success('成功',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取信息
|
|
|
* @ApiMethod (GET)
|
|
|
* @param string $UniqId UniqId
|
|
|
*/
|
|
|
@@ -125,14 +200,212 @@ class PackagingCountDocument extends Api
|
|
|
}else{
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+ $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
|
|
|
+ $rows = db()->table('db_包装计件')
|
|
|
+ ->field('LEFT(sczl_rq, 10) as sczl_rq, sczl_bh, sczl_bzdh, sczl_jsss, sczl_冲定额,
|
|
|
+ sczl_gdbh1, sczl_gdbh2, sczl_gdbh3, sczl_gdbh4, sczl_gdbh5, sczl_gdbh6,
|
|
|
+ rtrim(sczl_yjGx1) as sczl_yjGx1, rtrim(sczl_yjGx2) as sczl_yjGx2, rtrim(sczl_yjGx3) as sczl_yjGx3, rtrim(sczl_yjGx4) as sczl_yjGx4, rtrim(sczl_yjGx5) as sczl_yjGx5, rtrim(sczl_yjGx6) as sczl_yjGx6,
|
|
|
+ rtrim(sczl_gxmc1) as sczl_gxmc1, rtrim(sczl_gxmc2) as sczl_gxmc2, rtrim(sczl_gxmc3) as sczl_gxmc3, rtrim(sczl_gxmc4) as sczl_gxmc4, rtrim(sczl_gxmc5) as sczl_gxmc5, rtrim(sczl_gxmc6) as sczl_gxmc6,
|
|
|
+ sczl_cl1, sczl_cl2, sczl_cl3, sczl_cl4, sczl_cl5, sczl_cl6,
|
|
|
+ sczl_PgCl1, sczl_PgCl2, sczl_PgCl3, sczl_PgCl4, sczl_PgCl5, sczl_PgCl6,
|
|
|
+ sczl_返工产量1, sczl_返工产量2, sczl_返工产量3, sczl_返工产量4, sczl_返工产量5, sczl_返工产量6,
|
|
|
+ sczl_计产系数1, sczl_计产系数2, sczl_计产系数3, sczl_计产系数4, sczl_计产系数5, sczl_计产系数6,
|
|
|
+ rtrim(sczl_Jtbh1) as sczl_Jtbh1, rtrim(sczl_Jtbh2) as sczl_Jtbh2, rtrim(sczl_Jtbh3) as sczl_Jtbh3, rtrim(sczl_Jtbh4) as sczl_Jtbh4, rtrim(sczl_Jtbh5) as sczl_Jtbh5, rtrim(sczl_Jtbh6) as sczl_Jtbh6,
|
|
|
+ rtrim(sczl_dedh1) as sczl_dedh1, rtrim(sczl_dedh2) as sczl_dedh2, rtrim(sczl_dedh3) as sczl_dedh3, rtrim(sczl_dedh4) as sczl_dedh4, rtrim(sczl_dedh5) as sczl_dedh5, rtrim(sczl_dedh6) as sczl_dedh6,
|
|
|
+ rtrim(sczl_desc) as sczl_desc')
|
|
|
+ ->where('UniqId',$UniqId)
|
|
|
+ ->find();
|
|
|
+ $rs = db()->table('人事_基本资料')->where('员工编号',$rows['sczl_bh'])->find();
|
|
|
+ $rows['name'] = $rs ? trim($rs['员工姓名']) : '';
|
|
|
+ for ($i=1;$i<=6;$i++){
|
|
|
+ $rows['Gd_cpmc'.$i] = array_key_exists($rows['sczl_gdbh'.$i], $gd) ? trim($gd[$rows['sczl_gdbh'.$i]]) : '';
|
|
|
+ }
|
|
|
|
|
|
- $rows = db()->table('db_包装计件')->alias('d')
|
|
|
- ->field('d.*, ')
|
|
|
- ->join('工单_基本资料 g', 'd.')
|
|
|
- ->where('d.UniqId',$UniqId)
|
|
|
+ $this->success('成功',$rows);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询印件工序及产品名称
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $gdbh 工单编号
|
|
|
+ * @param string $gxmc 工序名称
|
|
|
+ */
|
|
|
+ public function getGxMc()
|
|
|
+ {
|
|
|
+ //get请求
|
|
|
+ if(!$this->request->isGet()){
|
|
|
+ $this->error('请求方式错误');
|
|
|
+ }
|
|
|
+ $req = $this->request->param();
|
|
|
+ if (isset($req['gdbh']) && !empty($req['gdbh'])){
|
|
|
+ $gdbh = $req['gdbh'];
|
|
|
+ }else{
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $gxmc = ['包装','成品防护'];
|
|
|
+
|
|
|
+ $rows = db()->table('工单_基本资料')->alias('g')
|
|
|
+ ->field('rtrim(g.Gd_cpmc) as Gd_cpmc, c.Gy0_yjno, c.Gy0_gxh, rtrim(c.Gy0_gxmc) as Gy0_gxmc')
|
|
|
+ ->where(['g.Gd_gdbh'=>$gdbh])
|
|
|
+ ->where('c.Gy0_gxmc',['like','%'.$gxmc[0].'%'],['like','%'.$gxmc[1].'%'],'OR')
|
|
|
+ ->join(['产品_印件资料'=>'j'],'g.Gd_cpdh=j.yj_yjdh and g.成品代号=j.yj_cpdh')
|
|
|
+ ->join(['工单_工艺资料'=>'c'],'c.Gy0_gdbh=g.Gd_gdbh and c.Gy0_yjno=j.yj_yjno')
|
|
|
->select();
|
|
|
|
|
|
+ foreach ($rows as $key=>$value){
|
|
|
+ $rows[$key]['jyGx'] = sprintf("%02d", $value['Gy0_yjno']).'-'.$value['Gy0_gxh'];
|
|
|
+ unset($rows[$key]['Gy0_yjno']);
|
|
|
+ unset($rows[$key]['Gy0_gxh']);
|
|
|
+ }
|
|
|
|
|
|
$this->success('成功',$rows);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string 'sys_id','sczl_rq',
|
|
|
+ 'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
|
|
|
+ 'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
|
|
|
+ 'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
|
|
|
+ 'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
|
|
|
+ 'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
|
|
|
+ 'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ //get请求
|
|
|
+ if(!$this->request->isPost()){
|
|
|
+ $this->error('请求方式错误');
|
|
|
+ }
|
|
|
+ $req = $this->request->param();
|
|
|
+ $arr = [
|
|
|
+ 'sys_id','sczl_rq',
|
|
|
+ 'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
|
|
|
+ 'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
|
|
|
+ 'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
|
|
|
+ 'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
|
|
|
+ 'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
|
|
|
+ 'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
|
|
|
+ ];
|
|
|
+ $data = [];
|
|
|
+ foreach ($arr as $key => $value){
|
|
|
+ if (!(isset($req[$value]) && trim($req[$value])!='')){
|
|
|
+ $this->error('参数错误',$value,$key+1);
|
|
|
+ }
|
|
|
+ $data[$value] = $req[$value];
|
|
|
+ }
|
|
|
+ $data['sys_rq'] = date('Y-m-d H:i:s');
|
|
|
+
|
|
|
+ //开启事务
|
|
|
+ db()->startTrans();
|
|
|
+ try{
|
|
|
+ $bool = db()->table('db_包装计件')->insert($data);
|
|
|
+
|
|
|
+ // 提交事务
|
|
|
+ db()->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ db()->rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if($bool===false) $this->error('失败');
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string 'UniqId','sczl_rq',
|
|
|
+ 'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
|
|
|
+ 'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
|
|
|
+ 'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
|
|
|
+ 'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
|
|
|
+ 'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
|
|
|
+ 'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
|
|
|
+ */
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ //get请求
|
|
|
+ if(!$this->request->isPost()){
|
|
|
+ $this->error('请求方式错误');
|
|
|
+ }
|
|
|
+ $req = $this->request->param();
|
|
|
+ $arr = [
|
|
|
+ 'sczl_rq',
|
|
|
+ 'sczl_gdbh1', 'sczl_gdbh2', 'sczl_gdbh3', 'sczl_gdbh4', 'sczl_gdbh5', 'sczl_gdbh6',
|
|
|
+ 'sczl_yjGx1', 'sczl_yjGx2', 'sczl_yjGx3', 'sczl_yjGx4', 'sczl_yjGx5', 'sczl_yjGx6',
|
|
|
+ 'sczl_gxmc1', 'sczl_gxmc2', 'sczl_gxmc3', 'sczl_gxmc4', 'sczl_gxmc5', 'sczl_gxmc6',
|
|
|
+ 'sczl_cl1', 'sczl_cl2', 'sczl_cl3', 'sczl_cl4', 'sczl_cl5', 'sczl_cl6',
|
|
|
+ 'sczl_PgCl1', 'sczl_PgCl2', 'sczl_PgCl3', 'sczl_PgCl4', 'sczl_PgCl5', 'sczl_PgCl6',
|
|
|
+ 'sczl_clAdd1', 'sczl_clAdd2', 'sczl_clAdd3', 'sczl_clAdd4', 'sczl_clAdd5', 'sczl_clAdd6'
|
|
|
+ ];
|
|
|
+ $data = [];
|
|
|
+ foreach ($arr as $key => $value){
|
|
|
+ if (!(isset($req[$value]) && trim($req[$value])!='')){
|
|
|
+ $this->error('参数错误',$value,$key+1);
|
|
|
+ }
|
|
|
+ $data[$value] = $req[$value];
|
|
|
+ }
|
|
|
+ if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
|
|
|
+ $this->error('参数错误','UniqId',100);
|
|
|
+ }
|
|
|
+ $data['mod_rq'] = date('Y-m-d H:i:s');
|
|
|
+
|
|
|
+ //开启事务
|
|
|
+ db()->startTrans();
|
|
|
+ try{
|
|
|
+ $bool = db()->table('db_包装计件')->where('UniqId',$req['UniqId'])->update($data);
|
|
|
+
|
|
|
+ // 提交事务
|
|
|
+ db()->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ db()->rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if($bool===false) $this->error('失败');
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string 'UniqId'
|
|
|
+ */
|
|
|
+ public function del()
|
|
|
+ {
|
|
|
+ //get请求
|
|
|
+ if(!$this->request->isPost()){
|
|
|
+ $this->error('请求方式错误');
|
|
|
+ }
|
|
|
+ $req = $this->request->param();
|
|
|
+
|
|
|
+ if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
|
|
|
+ $this->error('参数错误','UniqId',100);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开启事务
|
|
|
+ db()->startTrans();
|
|
|
+ try{
|
|
|
+ $bool = db()->table('db_包装计件')->where('UniqId',$req['UniqId'])->delete();
|
|
|
+
|
|
|
+ // 提交事务
|
|
|
+ db()->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ db()->rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if($bool===false) $this->error('失败');
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+
|
|
|
+ }
|
|
|
}
|