|
@@ -38,7 +38,6 @@ class WorkOrder extends Api
|
|
|
'progressAll' => $progressAll,
|
|
'progressAll' => $progressAll,
|
|
|
'印刷工单' => [],
|
|
'印刷工单' => [],
|
|
|
'糊盒工单' => []
|
|
'糊盒工单' => []
|
|
|
-
|
|
|
|
|
];
|
|
];
|
|
|
$sql = "SELECT DISTINCT
|
|
$sql = "SELECT DISTINCT
|
|
|
(客户编号),rtrim(客户名称 ) as 客户名称
|
|
(客户编号),rtrim(客户名称 ) as 客户名称
|
|
@@ -236,15 +235,10 @@ class WorkOrder extends Api
|
|
|
if ($value['Gy0_gxh']<10){
|
|
if ($value['Gy0_gxh']<10){
|
|
|
$value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
|
|
$value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
|
|
|
}
|
|
}
|
|
|
- if ((int)$value['Gy0_ms'] === 0){
|
|
|
|
|
- $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']);
|
|
|
|
|
- }else{
|
|
|
|
|
- $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']*$value['Gy0_ms']);
|
|
|
|
|
- }
|
|
|
|
|
if (rtrim($value['Gy0_sbbh']) == '' || $value['Gy0_计划接货数'] == 0){
|
|
if (rtrim($value['Gy0_sbbh']) == '' || $value['Gy0_计划接货数'] == 0){
|
|
|
$number = 0;
|
|
$number = 0;
|
|
|
}else{
|
|
}else{
|
|
|
- $number = round(($scrap/((int)($value['Gy0_计划接货数']/$value['Gy0_ls'])))*100,2).'%';
|
|
|
|
|
|
|
+ $number = round(((int)$value['Gy0_计划损耗']/(int)($value['Gy0_计划接货数']))*100,2).'%';
|
|
|
}
|
|
}
|
|
|
if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
|
|
if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
|
|
|
$status = '已完工';
|
|
$status = '已完工';
|
|
@@ -256,11 +250,11 @@ class WorkOrder extends Api
|
|
|
'印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
|
|
'印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
|
|
|
'备选工序' => rtrim($value['备选工序']),
|
|
'备选工序' => rtrim($value['备选工序']),
|
|
|
'工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
|
|
'工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
|
|
|
- '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
|
|
|
|
|
|
|
+ '计划产量' => $value['Gy0_计划接货数'],
|
|
|
'基础损耗' => rtrim($value['Gy0_Rate0']),
|
|
'基础损耗' => rtrim($value['Gy0_Rate0']),
|
|
|
'损耗率' => rtrim($value['Gy0_Rate1']),
|
|
'损耗率' => rtrim($value['Gy0_Rate1']),
|
|
|
'机台编号' => rtrim($value['Gy0_sbbh']),
|
|
'机台编号' => rtrim($value['Gy0_sbbh']),
|
|
|
- '报废定额' => $scrap,
|
|
|
|
|
|
|
+ '报废定额' => rtrim($value['Gy0_计划损耗']),
|
|
|
'允损比例' => $number,
|
|
'允损比例' => $number,
|
|
|
'难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
|
|
'难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
|
|
|
'损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
|
|
'损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
|
|
@@ -349,25 +343,23 @@ class WorkOrder extends Api
|
|
|
$field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
|
|
$field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
|
|
|
rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
|
|
rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
|
|
|
rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
|
|
rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
|
|
|
- rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
|
|
|
|
|
|
|
+ rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid,rtrim(计划投料) as 平张投料';
|
|
|
$list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
|
|
$list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
$this->error('未找到该工单信息');
|
|
$this->error('未找到该工单信息');
|
|
|
}
|
|
}
|
|
|
$printData = \db('工单_印件资料')
|
|
$printData = \db('工单_印件资料')
|
|
|
->where('Yj_Gdbh',$workOrder)
|
|
->where('Yj_Gdbh',$workOrder)
|
|
|
- ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料,rtrim(Uniqid) as id')
|
|
|
|
|
|
|
+ ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(Uniqid) as id')
|
|
|
->cache(true,84600)
|
|
->cache(true,84600)
|
|
|
->find();
|
|
->find();
|
|
|
if (empty($printData)){
|
|
if (empty($printData)){
|
|
|
$list['印件名称'] = '';
|
|
$list['印件名称'] = '';
|
|
|
$list['印件代号'] = '';
|
|
$list['印件代号'] = '';
|
|
|
- $list['平张投料'] = '';
|
|
|
|
|
$list['印件ID'] = '';
|
|
$list['印件ID'] = '';
|
|
|
}else{
|
|
}else{
|
|
|
$list['印件名称'] = $printData['印件名称'];
|
|
$list['印件名称'] = $printData['印件名称'];
|
|
|
$list['印件代号'] = $printData['印件代号'];
|
|
$list['印件代号'] = $printData['印件代号'];
|
|
|
- $list['平张投料'] = $printData['平张投料'];
|
|
|
|
|
$list['印件ID'] = $printData['id'];
|
|
$list['印件ID'] = $printData['id'];
|
|
|
}
|
|
}
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
@@ -417,8 +409,22 @@ class WorkOrder extends Api
|
|
|
'排产时库存' => isset($param['kc'])?$param['kc']:'',
|
|
'排产时库存' => isset($param['kc'])?$param['kc']:'',
|
|
|
'平均合格率' => isset($param['avg'])?$param['avg']:'',
|
|
'平均合格率' => isset($param['avg'])?$param['avg']:'',
|
|
|
];
|
|
];
|
|
|
|
|
+ //获取印件资料
|
|
|
|
|
+ $printCode = \db('工单_印件资料')
|
|
|
|
|
+ ->where('Uniqid',$param['printID'])
|
|
|
|
|
+ ->value('yj_Yjno');
|
|
|
|
|
+ if (empty($printCode)){
|
|
|
|
|
+ $this->success('未找到该工单印件资料');
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改工单工艺计划产量
|
|
|
|
|
+ $result = $this->PlannedProcessYield($param['gdbh'],$printCode,0,$param['jhtl']);
|
|
|
|
|
+ if ($result === false){
|
|
|
|
|
+ $this->success('分配工序计划产量失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改工单信息
|
|
|
$sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
|
|
$sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
|
|
|
$res = Db::query($sql);
|
|
$res = Db::query($sql);
|
|
|
|
|
+ //修改印件信息
|
|
|
$printSql = \db('工单_印件资料')
|
|
$printSql = \db('工单_印件资料')
|
|
|
->where('Uniqid',$param['printID'])
|
|
->where('Uniqid',$param['printID'])
|
|
|
->fetchSql(true)
|
|
->fetchSql(true)
|
|
@@ -990,6 +996,16 @@ class WorkOrder extends Api
|
|
|
'yj_ls' => isset($param['ls'])?$param['ls']:'',
|
|
'yj_ls' => isset($param['ls'])?$param['ls']:'',
|
|
|
'yj_desc' => isset($param['desc'])?$param['desc']:'',
|
|
'yj_desc' => isset($param['desc'])?$param['desc']:'',
|
|
|
];
|
|
];
|
|
|
|
|
+ //获取工单编号
|
|
|
|
|
+ $workOrder = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->field('Yj_Gdbh,yj_Yjno')->find();
|
|
|
|
|
+ if (empty($workOrder)){
|
|
|
|
|
+ $this->success('未找到该工单印件资料');
|
|
|
|
|
+ }
|
|
|
|
|
+ //重新分配工序计划产量
|
|
|
|
|
+ $result = $this->PlannedProcessYield($workOrder['Yj_Gdbh'],$workOrder['yj_Yjno'],0,$param['pztl']);
|
|
|
|
|
+ if ($result === false){
|
|
|
|
|
+ $this->success('修改工序产量失败');
|
|
|
|
|
+ }
|
|
|
$sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
|
|
$sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
|
|
|
$res = Db::query($sql);
|
|
$res = Db::query($sql);
|
|
|
if ($res !== false){
|
|
if ($res !== false){
|
|
@@ -1038,8 +1054,10 @@ class WorkOrder extends Api
|
|
|
'Gy0_小时产能' => $param['xscn'],
|
|
'Gy0_小时产能' => $param['xscn'],
|
|
|
'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
|
];
|
|
];
|
|
|
|
|
+ //修改工艺资料
|
|
|
$sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
|
|
$sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
|
|
|
$res = Db::query($sql);
|
|
$res = Db::query($sql);
|
|
|
|
|
+ //修改工单状态
|
|
|
$status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
|
|
$status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
|
|
|
if ($status['status'] !== '2-生产中'){
|
|
if ($status['status'] !== '2-生产中'){
|
|
|
$statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
|
|
$statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
|
|
@@ -1358,6 +1376,31 @@ class WorkOrder extends Api
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
$num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
|
|
$num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
|
|
|
|
|
+ //插入产品资料
|
|
|
|
|
+ $productData = \db('产品_基本资料')
|
|
|
|
|
+ ->where('产品编号',$param['cpdh'])
|
|
|
|
|
+ ->count();
|
|
|
|
|
+ if ($productData === 0) {
|
|
|
|
|
+ $clientCode = substr($param['cpdh'], 0, 5);
|
|
|
|
|
+ $product = [
|
|
|
|
|
+ '客户编号' => $clientCode,
|
|
|
|
|
+ '客户名称' => $param['khmc'],
|
|
|
|
|
+ '产品编号' => $param['cpdh'],
|
|
|
|
|
+ '产品名称' => $param['cpmc'],
|
|
|
|
|
+ '计量单位' => '万张',
|
|
|
|
|
+ '状态' => '',
|
|
|
|
|
+ 'Mod_rq' => date('Y-m-d H:i:s', time()),
|
|
|
|
|
+ 'UniqID' => \db('产品_基本资料')->order('UniqID desc')->value('UniqID') + 1,
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (strpos($product['产品名称'], '小盒') === false) {
|
|
|
|
|
+ $product['产品类别'] = '条盒';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $product['产品类别'] = '小盒';
|
|
|
|
|
+ }
|
|
|
|
|
+ $productSql = \db('产品_基本资料')->fetchSql(true)->insert($product);
|
|
|
|
|
+ \db()->query($productSql);
|
|
|
|
|
+ }
|
|
|
|
|
+ //添加工单
|
|
|
$productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
|
|
$productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
|
|
|
if (empty($productDetail)){
|
|
if (empty($productDetail)){
|
|
|
$productDetail['客户料号'] = '';
|
|
$productDetail['客户料号'] = '';
|
|
@@ -1429,15 +1472,15 @@ class WorkOrder extends Api
|
|
|
'待摊其他费用' => 0,
|
|
'待摊其他费用' => 0,
|
|
|
'加工费' => 0,
|
|
'加工费' => 0,
|
|
|
'加工费单价' => 0,
|
|
'加工费单价' => 0,
|
|
|
- '成本考核_胶印' => 0,
|
|
|
|
|
- '成本考核_凹印' => 0,
|
|
|
|
|
- '成本考核_丝印' => 0,
|
|
|
|
|
- '成本考核_模切' => 0,
|
|
|
|
|
- '成本考核_检验' => 0,
|
|
|
|
|
|
|
+ '成本考核_胶印' => 1,
|
|
|
|
|
+ '成本考核_凹印' => 1,
|
|
|
|
|
+ '成本考核_丝印' => 1,
|
|
|
|
|
+ '成本考核_模切' => 1,
|
|
|
|
|
+ '成本考核_检验' => 1,
|
|
|
'印版费' => 0,
|
|
'印版费' => 0,
|
|
|
'V23制造成本' => 0,
|
|
'V23制造成本' => 0,
|
|
|
'Prt_rq' => date('Y-m-d H:i:s',time()),
|
|
'Prt_rq' => date('Y-m-d H:i:s',time()),
|
|
|
- 'Sys_id' => '',
|
|
|
|
|
|
|
+ 'Sys_id' => $param['Sys_id'],
|
|
|
'Sys_rq' => date('Y-m-d H:i:s',time()),
|
|
'Sys_rq' => date('Y-m-d H:i:s',time()),
|
|
|
'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
|
'U8UID' => '',
|
|
'U8UID' => '',
|
|
@@ -1556,8 +1599,8 @@ class WorkOrder extends Api
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
$lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
|
|
$lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
|
|
|
- if ($lastId<1000000){
|
|
|
|
|
- $lastId = 1000000;
|
|
|
|
|
|
|
+ if (empty($lastId)){
|
|
|
|
|
+ $lastId = 0;
|
|
|
}else{
|
|
}else{
|
|
|
$lastId = $lastId + 1;
|
|
$lastId = $lastId + 1;
|
|
|
}
|
|
}
|
|
@@ -1589,8 +1632,8 @@ class WorkOrder extends Api
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
$lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
|
|
$lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
|
|
|
- if ($lastId<100000000){
|
|
|
|
|
- $lastId = 100000000;
|
|
|
|
|
|
|
+ if (empty($lastId)){
|
|
|
|
|
+ $lastId = 0;
|
|
|
}else{
|
|
}else{
|
|
|
$lastId = $lastId + 1;
|
|
$lastId = $lastId + 1;
|
|
|
}
|
|
}
|
|
@@ -1612,6 +1655,13 @@ class WorkOrder extends Api
|
|
|
->fetchSql(true)
|
|
->fetchSql(true)
|
|
|
->insert($param);
|
|
->insert($param);
|
|
|
$res = \db()->query($sql);
|
|
$res = \db()->query($sql);
|
|
|
|
|
+ //获取平张投料
|
|
|
|
|
+ $number = \db('工单_印件资料')
|
|
|
|
|
+ ->where('Yj_Gdbh',$param['Gy0_gdbh'])
|
|
|
|
|
+ ->where('yj_Yjno',$param['Gy0_yjno'])
|
|
|
|
|
+ ->value('rtrim(yj_平张投料)');
|
|
|
|
|
+ //分配工艺计划产量
|
|
|
|
|
+ $this->PlannedProcessYield($param['Gy0_gdbh'],$param['Gy0_yjno'],$param['Gy0_gxh'],$number);
|
|
|
if ($res !== false){
|
|
if ($res !== false){
|
|
|
$this->success('成功');
|
|
$this->success('成功');
|
|
|
}else{
|
|
}else{
|
|
@@ -1701,6 +1751,19 @@ class WorkOrder extends Api
|
|
|
}
|
|
}
|
|
|
$printId = explode(',',$param['UniqId']);
|
|
$printId = explode(',',$param['UniqId']);
|
|
|
$i = 0;
|
|
$i = 0;
|
|
|
|
|
+ //获取工单编号、印件号
|
|
|
|
|
+ $codeList = \db('工单_工艺资料')
|
|
|
|
|
+ ->where('UniqId',$printId[0])
|
|
|
|
|
+ ->field('rtrim(Gy0_gdbh) as 工单编号,rtrim(Gy0_yjno) as 印件号')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ //获取平张投料数量
|
|
|
|
|
+ $number = \db('工单_印件资料')
|
|
|
|
|
+ ->where([
|
|
|
|
|
+ 'Yj_Gdbh' => $codeList['工单编号'],
|
|
|
|
|
+ 'yj_Yjno' => $codeList['印件号']
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->value('rtrim(yj_平张投料)');
|
|
|
|
|
+ //循环删除工艺资料
|
|
|
foreach ($printId as $value){
|
|
foreach ($printId as $value){
|
|
|
$res = \db('工单_工艺资料')
|
|
$res = \db('工单_工艺资料')
|
|
|
->where('UniqId',$value)
|
|
->where('UniqId',$value)
|
|
@@ -1709,6 +1772,8 @@ class WorkOrder extends Api
|
|
|
$i++;
|
|
$i++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //重新分配工艺计划产量
|
|
|
|
|
+ $this->PlannedProcessYield($codeList['工单编号'],$codeList['印件号'],0,$number);
|
|
|
if ($i === 0){
|
|
if ($i === 0){
|
|
|
$this->success('删除成功');
|
|
$this->success('删除成功');
|
|
|
}else{
|
|
}else{
|
|
@@ -1729,18 +1794,13 @@ class WorkOrder extends Api
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
$param = $this->request->param();
|
|
$param = $this->request->param();
|
|
|
- if (isset($param['search']) === false){
|
|
|
|
|
|
|
+ if (empty($param['process'])){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
$order = \db('dic_lzsh')
|
|
$order = \db('dic_lzsh')
|
|
|
- ->where('sys_mc','like',substr($param['search'],0,6).'%')
|
|
|
|
|
|
|
+ ->where('sys_mc','like',$param['process'].'%')
|
|
|
->value('rtrim(sys_bh) as 编号');
|
|
->value('rtrim(sys_bh) as 编号');
|
|
|
- $list = \db('dic_lzsh')
|
|
|
|
|
- ->where('sys_bh','like',$order.'%')
|
|
|
|
|
- ->where('sys_bh','<>',$order)
|
|
|
|
|
- ->field('rtrim(sys_bh) as 编号,rtrim(sys_mc) as 名称,rtrim(UniqId) as UniqId')
|
|
|
|
|
- ->select();
|
|
|
|
|
- $this->success('成功',$list);
|
|
|
|
|
|
|
+ $this->success('成功',$order);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2040,6 +2100,11 @@ class WorkOrder extends Api
|
|
|
$ProcessList[$key]['Gy0_ks'] = $value['Gy0_Ks'];
|
|
$ProcessList[$key]['Gy0_ks'] = $value['Gy0_Ks'];
|
|
|
$ProcessList[$key]['Gy0_ms'] = $value['Gy0_Ms'];
|
|
$ProcessList[$key]['Gy0_ms'] = $value['Gy0_Ms'];
|
|
|
$ProcessList[$key]['Gy0_oil'] = $value['Gy0_Oil'];
|
|
$ProcessList[$key]['Gy0_oil'] = $value['Gy0_Oil'];
|
|
|
|
|
+ $ProcessList[$key]['Gy0_计划接货数'] = 0;
|
|
|
|
|
+ $ProcessList[$key]['Gy0_计划损耗'] = 0;
|
|
|
|
|
+ $ProcessList[$key]['无形损承担比例'] = 0;
|
|
|
|
|
+ $ProcessList[$key]['超节损承担比例'] = 0;
|
|
|
|
|
+ $ProcessList[$key]['超节损核算单价'] = 0;
|
|
|
$ProcessList[$key]['Gy0_sj1'] = '1900-01-01 00:00:00';
|
|
$ProcessList[$key]['Gy0_sj1'] = '1900-01-01 00:00:00';
|
|
|
$ProcessList[$key]['Gy0_sj2'] = '1900-01-01 00:00:00';
|
|
$ProcessList[$key]['Gy0_sj2'] = '1900-01-01 00:00:00';
|
|
|
$ProcessList[$key]['UniqId'] = $ProcesslastId + $key + 1;
|
|
$ProcessList[$key]['UniqId'] = $ProcesslastId + $key + 1;
|
|
@@ -2056,10 +2121,15 @@ class WorkOrder extends Api
|
|
|
$this->error('未找到印件资料');
|
|
$this->error('未找到印件资料');
|
|
|
}
|
|
}
|
|
|
$PrintLastId = \db('工单_印件资料')->order('Uniqid desc')->value('rtrim(Uniqid)');
|
|
$PrintLastId = \db('工单_印件资料')->order('Uniqid desc')->value('rtrim(Uniqid)');
|
|
|
|
|
+ $number = \db('工单_基本资料')
|
|
|
|
|
+ ->where('Gd_gdbh',$param['workorder'])
|
|
|
|
|
+ ->where('成品代号',$param['productCode'])
|
|
|
|
|
+ ->value('rtrim(计划投料)');
|
|
|
foreach ($PrintList as $key => $value){
|
|
foreach ($PrintList as $key => $value){
|
|
|
$PrintList[$key]['Yj_Gdbh'] = $param['workorder'];
|
|
$PrintList[$key]['Yj_Gdbh'] = $param['workorder'];
|
|
|
$PrintList[$key]['yj_Yjno'] = $value['yj_yjno'];
|
|
$PrintList[$key]['yj_Yjno'] = $value['yj_yjno'];
|
|
|
$PrintList[$key]['yj_Yjdh'] = $value['yj_yjdh'];
|
|
$PrintList[$key]['yj_Yjdh'] = $value['yj_yjdh'];
|
|
|
|
|
+ $PrintList[$key]['yj_平张投料'] = $number;
|
|
|
$PrintList[$key]['Sys_id'] = $value['sys_id'];
|
|
$PrintList[$key]['Sys_id'] = $value['sys_id'];
|
|
|
$PrintList[$key]['Uniqid'] = $PrintLastId + $key + 1;
|
|
$PrintList[$key]['Uniqid'] = $PrintLastId + $key + 1;
|
|
|
$PrintList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
|
|
$PrintList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
|
|
@@ -2077,6 +2147,12 @@ class WorkOrder extends Api
|
|
|
if ($printRes === false){
|
|
if ($printRes === false){
|
|
|
$this->error('插入印件资料失败');
|
|
$this->error('插入印件资料失败');
|
|
|
}
|
|
}
|
|
|
|
|
+ //计算工序计划生产数量
|
|
|
|
|
+ if ($number !== 0){
|
|
|
|
|
+ foreach ($PrintList as $value){
|
|
|
|
|
+ $this->PlannedProcessYield($param['workorder'],$value['yj_Yjno'],0,$number);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
$this->success('成功');
|
|
$this->success('成功');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2120,4 +2196,121 @@ class WorkOrder extends Api
|
|
|
$this->success('成功',$list);
|
|
$this->success('成功',$list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工艺资料计划产量重新分配
|
|
|
|
|
+ * @param string $workOrder 工单
|
|
|
|
|
+ * @param int $yjno 印件号
|
|
|
|
|
+ * @param int $gxh 工序号
|
|
|
|
|
+ * @param int $feed 平张投料
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ * @throws \think\Exception
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function PlannedProcessYield($workOrder,$yjno,$gxh,$feed)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($gxh === 0){
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh'=>$workOrder,
|
|
|
|
|
+ 'Gy0_yjno'=>$yjno,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'Gy0_gdbh'=>$workOrder,
|
|
|
|
|
+ 'Gy0_yjno'=>$yjno,
|
|
|
|
|
+ 'Gy0_gxh'=>['>=',$gxh]
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取工艺资料
|
|
|
|
|
+ $processList = \db('工单_工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('Gy0_Rate0 as 损耗定额,Gy0_Rate1 as 损耗率,rtrim(损耗系数) as 损耗系数,Gy0_ms,Gy0_ls,UniqId')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($processList)){
|
|
|
|
|
+ $this->success('未找到该工单工序资料');
|
|
|
|
|
+ }
|
|
|
|
|
+ //计算损耗定额和计划产量
|
|
|
|
|
+ $production = [];
|
|
|
|
|
+ $i = 0;
|
|
|
|
|
+ foreach ($processList as $key=>$value){
|
|
|
|
|
+ if ($key === 0){
|
|
|
|
|
+ array_push($production,$feed);
|
|
|
|
|
+ }
|
|
|
|
|
+ $wastage = 0;
|
|
|
|
|
+ if ($value['损耗率'] !== 0 && !empty($value['损耗率'])){
|
|
|
|
|
+ $wastage = ($production[$key]*$value['损耗率']+$value['损耗定额'])*$value['损耗系数'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($value['Gy0_ms'] >0 && !empty($value['Gy0_ms'])){
|
|
|
|
|
+ $wastage = round($wastage * $value['Gy0_ms']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ((int)$value['Gy0_ls'] === 1 && $key>=1){
|
|
|
|
|
+ $number = $production[$key]*$processList[$key-1]['Gy0_ls'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $number = $production[$key];
|
|
|
|
|
+ }
|
|
|
|
|
+ array_push($production,ceil($number-$wastage));
|
|
|
|
|
+ $processSql = \db('工单_工艺资料')
|
|
|
|
|
+ ->where('UniqId',$value['UniqId'])
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update(['Gy0_计划接货数'=>$production[$key],'Gy0_计划损耗'=>$wastage]);
|
|
|
|
|
+ $res = \db()->query($processSql);
|
|
|
|
|
+ if ($res === false){
|
|
|
|
|
+ $i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($i===0){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工单资料删除
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function WorkOrderDel()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (isset($param['UniqId']) === false){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $WorkOrderId = explode(',',$param['UniqId']);
|
|
|
|
|
+ $i = 0;
|
|
|
|
|
+ foreach ($WorkOrderId as $key=>$value){
|
|
|
|
|
+ //获取工单编号
|
|
|
|
|
+ $workorder = \db('工单_基本资料')
|
|
|
|
|
+ ->where('Uniqid',$value)
|
|
|
|
|
+ ->value('rtrim(Gd_gdbh)');
|
|
|
|
|
+ //删除工单资料、工艺资料、印件资料
|
|
|
|
|
+ \db()->startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ \db('工单_基本资料')->where('Uniqid',$value)->delete();
|
|
|
|
|
+ if (!empty(\db('工单_工艺资料')->where('Gy0_gdbh',$workorder)->find())){
|
|
|
|
|
+ \db('工单_工艺资料')->where('Gy0_gdbh',$workorder)->delete();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty(\db('工单_印件资料')->where('Yj_Gdbh',$workorder)->find())){
|
|
|
|
|
+ \db('工单_印件资料')->where('Yj_Gdbh',$workorder)->delete();
|
|
|
|
|
+ }
|
|
|
|
|
+ \db()->commit();
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
|
+ \db()->rollback();
|
|
|
|
|
+ $i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($i === 0){
|
|
|
|
|
+ $this->success('删除成功');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->error('删除失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|