|
@@ -14,6 +14,34 @@ class Manufacture extends Api
|
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedRight = ['*'];
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
|
|
|
|
+ //查找工单
|
|
|
|
|
+ public function WorkOrderSearch(){
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $workOder = input('workOrder');
|
|
|
|
|
+ $printName = input('printName');
|
|
|
|
|
+ if (empty($workOder)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gd_gdbh' => $workOder
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (!empty($printName)){
|
|
|
|
|
+ $where['成品名称'] = $printName;
|
|
|
|
|
+ }
|
|
|
|
|
+ $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
|
|
|
|
|
+ rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
|
|
|
|
|
+ rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
|
|
|
|
|
+ rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
|
|
|
|
|
+ $list = Db::table('工单_基本资料')->where($where)->field($field)->find();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到该工单');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 计划中工单
|
|
* 计划中工单
|
|
|
* @ApiMethod (GET)
|
|
* @ApiMethod (GET)
|
|
@@ -40,8 +68,6 @@ class Manufacture extends Api
|
|
|
$this->error('失败');
|
|
$this->error('失败');
|
|
|
}
|
|
}
|
|
|
foreach ($list as $key=>$value){
|
|
foreach ($list as $key=>$value){
|
|
|
-// $cateGory = Db::table('产品_基本资料')->where('产品编号',$value['产品代号'])->find();
|
|
|
|
|
-// $list[$key]['产品类别'] = $cateGory['产品类别'];
|
|
|
|
|
$list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
|
|
$list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
@@ -87,7 +113,7 @@ class Manufacture extends Api
|
|
|
}else{
|
|
}else{
|
|
|
$list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
|
|
$list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
|
|
|
}
|
|
}
|
|
|
- unset($list[$key]['Gy0_yjno'],$list[$key]['Gy0_gxh'],$list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
|
|
|
|
|
|
|
+ unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
|
}
|
|
}
|
|
@@ -190,7 +216,7 @@ class Manufacture extends Api
|
|
|
}else{
|
|
}else{
|
|
|
$list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
|
|
$list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
|
|
|
}
|
|
}
|
|
|
- unset($list[$key]['Gy0_yjno'],$list[$key]['Gy0_gxh'],$list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
|
|
|
|
|
|
|
+ unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
|
|
|
$list[$key]['机组'] = $value['设备编号'];
|
|
$list[$key]['机组'] = $value['设备编号'];
|
|
|
$orderDetail = Db::table('工单_基本资料')->where('Gd_gdbh',$list[$key]['工单编号'])->field('rtrim(计划投料) as 计划投料')->find();
|
|
$orderDetail = Db::table('工单_基本资料')->where('Gd_gdbh',$list[$key]['工单编号'])->field('rtrim(计划投料) as 计划投料')->find();
|
|
|
$list[$key]['工序产量'] = $orderDetail['计划投料'];
|
|
$list[$key]['工序产量'] = $orderDetail['计划投料'];
|
|
@@ -215,16 +241,16 @@ class Manufacture extends Api
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
$data = [];
|
|
$data = [];
|
|
|
- $department = Db::table('设备_基本资料')->distinct(true)->column('使用部门');
|
|
|
|
|
|
|
+ $department = Db::table('设备_基本资料')->distinct(true)->cache(true)->column('使用部门');
|
|
|
if (empty($department)){
|
|
if (empty($department)){
|
|
|
$this->error('为获取到机台数据');
|
|
$this->error('为获取到机台数据');
|
|
|
}
|
|
}
|
|
|
foreach ($department as $value){
|
|
foreach ($department as $value){
|
|
|
if (rtrim($value) !== '研发中心'){
|
|
if (rtrim($value) !== '研发中心'){
|
|
|
- $benchClass = Db::table('设备_基本资料')->where('使用部门',$value)->distinct(true)->column('设备编组');
|
|
|
|
|
|
|
+ $benchClass = Db::table('设备_基本资料')->where('使用部门',$value)->distinct(true)->cache(true)->column('设备编组');
|
|
|
foreach ($benchClass as $v){
|
|
foreach ($benchClass as $v){
|
|
|
if (rtrim($v) !== ''){
|
|
if (rtrim($v) !== ''){
|
|
|
- $machine = Db::table('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
|
|
|
|
|
|
|
+ $machine = Db::table('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
|
|
|
foreach ($machine as $kk=>$vv){
|
|
foreach ($machine as $kk=>$vv){
|
|
|
$data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
|
|
$data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
|
|
|
}
|
|
}
|
|
@@ -234,4 +260,343 @@ class Manufacture extends Api
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$data);
|
|
$this->success('成功',$data);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工单状态设置
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param string $workOrder 工单编号
|
|
|
|
|
+ * @param string $status 工单状态
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function StatusEdit()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $workOrder = input('workOrder');
|
|
|
|
|
+ $status = input('status');
|
|
|
|
|
+ if (empty($workOrder) || empty($status)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status]);
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ if ($res !== false){
|
|
|
|
|
+ $this->success('成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更改工序状态
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param void
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function complete()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = $this->request->param();
|
|
|
|
|
+ if (empty($data)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh' => $data['workOrder'],
|
|
|
|
|
+ 'Gy0_gxh' => $data['processCode']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $sql = Db::table('工单_工艺资料')->where($where)->fetchSql(true)->update(['PD_WG'=>date('Y-m-d H:i:s',time())]);
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ if ($res !== false){
|
|
|
|
|
+ $this->success('成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 加入排产
|
|
|
|
|
+ * @ApiMethod (POST)
|
|
|
|
|
+ * @param void $data
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public function ProductionSchedulingAdd()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = $this->request->param();
|
|
|
|
|
+ if (empty($data)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh' => $data['workOrder'],
|
|
|
|
|
+ 'Gy0_sbbh' => $data['machine'],
|
|
|
|
|
+ 'Gy0_yjno' => $data['printCode'],
|
|
|
|
|
+ 'Gy0_gxh' => $data['processCode']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $lastTime = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where(['Gy0_sbbh'=>$where['Gy0_sbbh'],'Gy0_sj2'=>['<>','1900-01-01 00:00:00'],'Gy0_sj2'=>['<','2099-01-01 00:00:00']])
|
|
|
|
|
+ ->field('rtrim(Gy0_sj2) as sj2')
|
|
|
|
|
+ ->order('Gy0_sj2 desc')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ $row = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
|
|
|
+ $sql = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update(['Gy0_sj1'=>$lastTime['sj2'],'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ if ($res !== false){
|
|
|
|
|
+ $this->success('成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 暂停排产
|
|
|
|
|
+ * @ApiMethod (POST)
|
|
|
|
|
+ * @param void $data
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public function ProductionSchedulingPause()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = $this->request->param();
|
|
|
|
|
+ if (empty($data)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh' => $data['workOrder'],
|
|
|
|
|
+ 'Gy0_sbbh' => $data['machine'],
|
|
|
|
|
+ 'Gy0_yjno' => $data['printCode'],
|
|
|
|
|
+ 'Gy0_gxh' => $data['processCode']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $machine = $where['Gy0_sbbh'];
|
|
|
|
|
+ $endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
|
|
|
|
|
+ if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
|
|
|
|
|
+ $this->error('该工单不是制程中工单');
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update(['Gy0_sj1'=>'1900-01-01 00:00:00','Gy0_sj2'=>'1900-01-01 00:00:00','Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
|
|
+ $row = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh = '{$machine}' AND Gy0_sj1 >= '{$endTime}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
|
|
|
|
|
+ $rechres = Db::query($rechSql);
|
|
|
|
|
+ if ($res !== false && $rechres !== false){
|
|
|
|
|
+ $this->success('成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工序状态更正
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param void $param
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function ProcessStatusCorrection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh' => $param['workOrder'],
|
|
|
|
|
+ 'Gy0_sbbh' => ['<>','']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $workOrder = $where['Gy0_gdbh'];
|
|
|
|
|
+ $field = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_sbbh) as 设备代号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_ls) as ls,rtrim(PD_WG) as 完工时间';
|
|
|
|
|
+ $list = Db::table('工单_工艺资料')->where($where)->field($field)->order('Gy0_gxh')->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到该工单工艺资料');
|
|
|
|
|
+ }
|
|
|
|
|
+ $yieldSql = "SELECT a.Gy0_gxh as gxh,SUM(b.sczl_cl) as cl FROM `工单_工艺资料` AS a JOIN `设备_产量计酬` as b ON a.Gy0_gxh = b.sczl_gxh WHERE a.Gy0_gdbh = '{$workOrder}' AND b.sczl_gdbh = '{$workOrder}' GROUP BY a.Gy0_gxh";
|
|
|
|
|
+ $yield = Db::query($yieldSql);
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ if ($value['yjno']<10){
|
|
|
|
|
+ $value['yjno'] = '0'.$value['yjno'];
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($value['gxh']<10){
|
|
|
|
|
+ $value['gxh'] = '0'.$value['gxh'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
|
|
|
|
|
+ foreach ($yield as $k=>$v){
|
|
|
|
|
+ if ($v['gxh'] === $list[$key]['gxh']){
|
|
|
|
|
+ $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/'.$v['cl'];
|
|
|
|
|
+ $list[$key]['完成率'] = number_format($v['cl']/($value['计划接货数']/$value['ls']),4)*100 . '%';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/0';
|
|
|
|
|
+ $list[$key]['完成率'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($value['完工时间'] == '1900-01-01 00:00:00') {
|
|
|
|
|
+ $list[$key]['完工时间'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['计划接货数'],$list[$key]['ls']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 班次选择
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function ScheduleSelection()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = Db::table('工单_排程班次')->field('rtrim(bcdh) as 班次代号,rtrim(desc_) as desc_,rtrim(stdtime) as stdtime')->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到班次数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ $list[$key]['detail'] = $value['班次代号'].'||'.$value['desc_'].'||'.$value['stdtime'];
|
|
|
|
|
+ unset($list[$key]['desc_'],$list[$key]['stdtime']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车间设备排程展示
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param void $param
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ public function EquipmentScheduling()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_sbbh' => $param['machine'],
|
|
|
|
|
+ 'Gy0_sj1' => ['between',['1900-01-01 00:00:01','2098-12-31 23:59:59']],
|
|
|
|
|
+ 'PD_WG' => '1900-01-01 00:00:00'
|
|
|
|
|
+ ];
|
|
|
|
|
+ $machine = $where['Gy0_sbbh'];
|
|
|
|
|
+ if (isset($param['class'])){
|
|
|
|
|
+ $where['Gy0_班次安排'] = $param['class'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,
|
|
|
|
|
+ rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,rtrim(Gy0_班次安排) as 班次安排,rtrim(工序备注) as 排单备注,
|
|
|
|
|
+ rtrim(Gy0_最早开工时间) as 最早开工时间,rtrim(Gy0_sj1) as 计划开工时间,rtrim(Gy0_sj2) as 计划完工时间,rtrim(Gy0_yjno) as yjno,
|
|
|
|
|
+ rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_ls) as ls';
|
|
|
|
|
+ $list = Db::table('工单_工艺资料')->where($where)->field($filed)->cache(true)->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到该机台制程中产品');
|
|
|
|
|
+ }
|
|
|
|
|
+ $Sql = "SELECT SUM(c.sczl_cl) as 已完成,rtrim(c.sczl_gdbh) as gdbh
|
|
|
|
|
+ FROM `工单_工艺资料` AS a JOIN `设备_产量计酬` AS c ON a.Gy0_gdbh = c.sczl_gdbh
|
|
|
|
|
+ AND a.Gy0_gxh = c.sczl_gxh WHERE a.Gy0_sbbh = '{$machine}' AND a.Gy0_sj1 > '1900-01-01 00:00:00'
|
|
|
|
|
+ AND a.Gy0_sj1 < '2099-01-01 00:00:00' AND a.PD_WG = '1900-01-01 00:00:00' GROUP BY a.Gy0_gdbh";
|
|
|
|
|
+ $res = Db::query($Sql);
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ $list[$key]['计划接货数'] = (int)round($value['计划接货数']/$value['ls']);
|
|
|
|
|
+ if ($value['yjno']<10){
|
|
|
|
|
+ $value['yjno'] = '0'.$value['yjno'];
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($value['gxh']<10){
|
|
|
|
|
+ $value['gxh'] = '0'.$value['gxh'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $list[$key]['印件/工序'] = $value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
|
|
|
|
|
+ unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['ls']);
|
|
|
|
|
+ $list[$key]['已完成'] = 0;
|
|
|
|
|
+ foreach ($res as $k=>$v){
|
|
|
|
|
+ if ($value['工单编号'] === $v['gdbh']){
|
|
|
|
|
+ $list[$key]['已完成'] = $v['已完成'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车间设备排程编辑
|
|
|
|
|
+ * @ApiMethod (POST)
|
|
|
|
|
+ * @param void $param
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function EquipmentSchedulingEdit()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ 'Gy0_小时产能' => $param['capacity'],
|
|
|
|
|
+ 'Gy0_生产工时' => $param['ProductionHours'],
|
|
|
|
|
+ 'Gy0_辅助工时' => $param['AuxiliaryHours'],
|
|
|
|
|
+ 'Gy0_班次安排' => $param['shift'],
|
|
|
|
|
+ '工序备注' => $param['remark'],
|
|
|
|
|
+ 'Gy0_最早开工时间' => $param['start']=''?'1900-01-01 00:00:00':$param['start'],
|
|
|
|
|
+ 'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($param['projectTime'])),
|
|
|
|
|
+ 'Gy0_sj2' => date('Y-m-d HY-m-d',strtotime($param['projectTime'])+(ceil($param['ProductionHours'])+ceil($param['AuxiliaryHours']))*3600),
|
|
|
|
|
+ ];
|
|
|
|
|
+ $sql = Db::table('工单_工艺资料')
|
|
|
|
|
+ ->where(['Gy0_gdbh'=>$param['workOrder'],'Gy0_sbbh'=>$param['machine']])
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update($data);
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ if ($res !== false){
|
|
|
|
|
+ $this->success('成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|