|
@@ -4,7 +4,9 @@ namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\controller\Api;
|
|
use app\common\controller\Api;
|
|
|
|
|
+use Monolog\Handler\IFTTTHandler;
|
|
|
use think\Db;
|
|
use think\Db;
|
|
|
|
|
+use think\Request;
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
* 生产排单管理
|
|
* 生产排单管理
|
|
@@ -55,15 +57,24 @@ class Manufacture extends Api
|
|
|
if ($this->request->isGet() === false){
|
|
if ($this->request->isGet() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($param['status'] === '计划中'){
|
|
|
|
|
+ $status = '计划中';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $status = '已完工';
|
|
|
|
|
+ }
|
|
|
$where = [
|
|
$where = [
|
|
|
- 'gd_statu' => '3-计划中',
|
|
|
|
|
|
|
+ 'gd_statu' => ['LIKE','%'.$status],
|
|
|
'行号' => '1',
|
|
'行号' => '1',
|
|
|
];
|
|
];
|
|
|
$field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
|
|
$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(接单日期) 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(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 销售订单号';
|
|
rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
|
|
|
- $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
|
|
|
|
|
|
|
+ $list = Db::table('工单_基本资料')->where($where)->field($field)->limit(1000)->order('Uniqid desc')->select();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
$this->error('失败');
|
|
$this->error('失败');
|
|
|
}
|
|
}
|
|
@@ -168,14 +179,65 @@ class Manufacture extends Api
|
|
|
if ($this->request->isGet() === false){
|
|
if ($this->request->isGet() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
- $where = [
|
|
|
|
|
- 'gd_statu' => '2-生产中',
|
|
|
|
|
- '行号' => 1
|
|
|
|
|
- ];
|
|
|
|
|
- $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(接单日期) as 接单日期,
|
|
|
|
|
- rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(销售订单号) as 销售订单号,rtrim(Gd_客户代号) as 客户编号,
|
|
|
|
|
- rtrim(Gd_客户名称) as 客户名称,rtrim(客户料号) as 客户料号,rtrim(Uniqid) as GDUID';
|
|
|
|
|
- $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
|
|
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($param['status'] === '排程中'){
|
|
|
|
|
+ $sql = "SELECT
|
|
|
|
|
+ rtrim(a.Gd_gdbh) AS 工单编号,
|
|
|
|
|
+ rtrim(a.Gd_cpdh) AS 产品代号,
|
|
|
|
|
+ rtrim(a.Gd_cpmc) AS 产品名称,
|
|
|
|
|
+ rtrim(a.接单日期) AS 接单日期,
|
|
|
|
|
+ rtrim(a.交货日期) AS 交货日期,
|
|
|
|
|
+ rtrim(a.订单数量) AS 订单数量,
|
|
|
|
|
+ rtrim(a.计量单位) AS 计量单位,
|
|
|
|
|
+ rtrim(a.销售订单号) AS 销售订单号,
|
|
|
|
|
+ rtrim(a.Gd_客户代号) AS 客户编号,
|
|
|
|
|
+ rtrim(a.Gd_客户名称) AS 客户名称,
|
|
|
|
|
+ rtrim(a.客户料号) AS 客户料号,
|
|
|
|
|
+ rtrim(a.Uniqid) AS GDUID
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `工单_基本资料` AS a
|
|
|
|
|
+ INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
|
|
|
|
|
+ JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.gd_statu = '2-生产中'
|
|
|
|
|
+ AND a.行号 = '1'
|
|
|
|
|
+ AND b.PD_WG = '1900-01-01 00:00:00'
|
|
|
|
|
+ AND b.Gy0_sj1 = '1900-01-01 00:00:00'
|
|
|
|
|
+ AND c.状态 = ''
|
|
|
|
|
+ GROUP BY a.Gd_gdbh ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $sql = "SELECT
|
|
|
|
|
+ rtrim(a.Gd_gdbh) AS 工单编号,
|
|
|
|
|
+ rtrim(a.Gd_cpdh) AS 产品代号,
|
|
|
|
|
+ rtrim(a.Gd_cpmc) AS 产品名称,
|
|
|
|
|
+ rtrim(a.接单日期) AS 接单日期,
|
|
|
|
|
+ rtrim(a.交货日期) AS 交货日期,
|
|
|
|
|
+ rtrim(a.订单数量) AS 订单数量,
|
|
|
|
|
+ rtrim(a.计量单位) AS 计量单位,
|
|
|
|
|
+ rtrim(a.销售订单号) AS 销售订单号,
|
|
|
|
|
+ rtrim(a.Gd_客户代号) AS 客户编号,
|
|
|
|
|
+ rtrim(a.Gd_客户名称) AS 客户名称,
|
|
|
|
|
+ rtrim(a.客户料号) AS 客户料号,
|
|
|
|
|
+ rtrim(a.Uniqid) AS GDUID
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `工单_基本资料` AS a
|
|
|
|
|
+ INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
|
|
|
|
|
+ JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.gd_statu = '2-生产中'
|
|
|
|
|
+ AND a.行号 = '1'
|
|
|
|
|
+ AND b.PD_WG = '1900-01-01 00:00:00'
|
|
|
|
|
+ AND b.Gy0_sj1 != '1900-01-01 00:00:00'
|
|
|
|
|
+ AND c.状态 = ''
|
|
|
|
|
+ GROUP BY a.Gd_gdbh ";
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = Db::query($sql);
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->error('未找到工单信息');
|
|
|
|
|
+ }
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -280,7 +342,7 @@ class Manufacture extends Api
|
|
|
*/
|
|
*/
|
|
|
public function StatusEdit()
|
|
public function StatusEdit()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost() === false){
|
|
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
$workOrder = input('workOrder');
|
|
$workOrder = input('workOrder');
|
|
@@ -341,10 +403,10 @@ class Manufacture extends Api
|
|
|
|
|
|
|
|
public function ProductionSchedulingAdd()
|
|
public function ProductionSchedulingAdd()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost() === false){
|
|
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
- $data = $this->request->param();
|
|
|
|
|
|
|
+ $data = Request::instance()->post();
|
|
|
if (empty($data)){
|
|
if (empty($data)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
@@ -363,6 +425,9 @@ class Manufacture extends Api
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
->find();
|
|
->find();
|
|
|
|
|
+ if (empty($row)){
|
|
|
|
|
+ $this->error('未找到该工单工艺资料');
|
|
|
|
|
+ }
|
|
|
$endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
$endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
|
$sql = Db::table('工单_工艺资料')
|
|
$sql = Db::table('工单_工艺资料')
|
|
|
->where($where)
|
|
->where($where)
|
|
@@ -390,10 +455,10 @@ class Manufacture extends Api
|
|
|
|
|
|
|
|
public function ProductionSchedulingPause()
|
|
public function ProductionSchedulingPause()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost() === false){
|
|
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
- $data = $this->request->param();
|
|
|
|
|
|
|
+ $data = Request::instance()->post();
|
|
|
if (empty($data)){
|
|
if (empty($data)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
@@ -405,6 +470,9 @@ class Manufacture extends Api
|
|
|
];
|
|
];
|
|
|
$machine = $where['Gy0_sbbh'];
|
|
$machine = $where['Gy0_sbbh'];
|
|
|
$endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
|
|
$endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
|
|
|
|
|
+ if (empty($endTime)){
|
|
|
|
|
+ $this->error('未找到该工序');
|
|
|
|
|
+ }
|
|
|
if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
|
|
if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
|
|
|
$this->error('该工单不是制程中工单');
|
|
$this->error('该工单不是制程中工单');
|
|
|
}
|
|
}
|
|
@@ -416,6 +484,9 @@ class Manufacture extends Api
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
->find();
|
|
->find();
|
|
|
|
|
+ if (empty($row)){
|
|
|
|
|
+ $this->error('未找到该工序');
|
|
|
|
|
+ }
|
|
|
$number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
|
|
$number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
|
|
|
$res = Db::query($sql);
|
|
$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'";
|
|
$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'";
|
|
@@ -467,7 +538,7 @@ class Manufacture extends Api
|
|
|
$list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
|
|
$list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
|
|
|
foreach ($yield as $k=>$v){
|
|
foreach ($yield as $k=>$v){
|
|
|
if ($v['gxh'] === $list[$key]['gxh']){
|
|
if ($v['gxh'] === $list[$key]['gxh']){
|
|
|
- $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/'.$v['cl'];
|
|
|
|
|
|
|
+ $list[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$v['cl'];
|
|
|
$list[$key]['完成率'] = number_format($v['cl']/($value['计划接货数']/$value['ls']),4)*100 . '%';
|
|
$list[$key]['完成率'] = number_format($v['cl']/($value['计划接货数']/$value['ls']),4)*100 . '%';
|
|
|
}else{
|
|
}else{
|
|
|
$list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/0';
|
|
$list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/0';
|
|
@@ -482,6 +553,15 @@ class Manufacture extends Api
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //工序状态更正->工序状态编辑
|
|
|
|
|
+ public function ProcessStatusCorrectionEdit()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 班次选择
|
|
* 班次选择
|
|
|
* @ApiMethod (GET)
|
|
* @ApiMethod (GET)
|
|
@@ -507,7 +587,7 @@ class Manufacture extends Api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 车间设备排程展示
|
|
|
|
|
|
|
+ * 车间设备制程展示
|
|
|
* @ApiMethod (GET)
|
|
* @ApiMethod (GET)
|
|
|
* @param void $param
|
|
* @param void $param
|
|
|
* @return void
|
|
* @return void
|
|
@@ -577,11 +657,11 @@ class Manufacture extends Api
|
|
|
*/
|
|
*/
|
|
|
public function EquipmentSchedulingEdit()
|
|
public function EquipmentSchedulingEdit()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isPost() === false){
|
|
|
|
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $param = $this->request->param();
|
|
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
if (empty($param)){
|
|
if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|