|
|
@@ -187,7 +187,7 @@ class WorkOrder extends Api
|
|
|
//印件资料
|
|
|
$printList = \db('工单_印件资料')
|
|
|
->where('Yj_Gdbh',$Gd_gdbh)
|
|
|
- ->cache(true,84600)
|
|
|
+// ->cache(true,84600)
|
|
|
->select();
|
|
|
if (!empty($printList)){
|
|
|
foreach ($printList as $key=>$value){
|
|
|
@@ -228,7 +228,7 @@ class WorkOrder extends Api
|
|
|
//工艺资料
|
|
|
$processList = \db('工单_工艺资料')
|
|
|
->where('Gy0_gdbh',$Gd_gdbh)
|
|
|
- ->cache(true,84600)
|
|
|
+// ->cache(true,84600)
|
|
|
->select();
|
|
|
if (!empty($processList)){
|
|
|
foreach ($processList as $key=>$value){
|
|
|
@@ -238,11 +238,12 @@ class WorkOrder extends Api
|
|
|
if ($value['Gy0_gxh']<10){
|
|
|
$value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
|
|
|
}
|
|
|
- if ((int)$value['Gy0_计划损耗'] !== 0){
|
|
|
- $number = round(((int)$value['Gy0_计划损耗']/(int)($value['Gy0_计划接货数']/$value['Gy0_ls'])),2).'%';
|
|
|
+ if ((int)$value['Gy0_ms'] === 0){
|
|
|
+ $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']);
|
|
|
}else{
|
|
|
- $number = 0;
|
|
|
+ $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']*$value['Gy0_ms']);
|
|
|
}
|
|
|
+ $number = round(($scrap/((int)($value['Gy0_计划接货数']/$value['Gy0_ls'])))*100,2).'%';
|
|
|
if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
|
|
|
$status = '已完工';
|
|
|
}else{
|
|
|
@@ -256,7 +257,7 @@ class WorkOrder extends Api
|
|
|
'计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
|
|
|
'基础损耗' => rtrim($value['Gy0_Rate0']),
|
|
|
'损耗率' => rtrim($value['Gy0_Rate1']),
|
|
|
- '报废定额' => rtrim($value['Gy0_计划损耗']),
|
|
|
+ '报废定额' => $scrap,
|
|
|
'允损比例' => $number,
|
|
|
'难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
|
|
|
'损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
|
|
|
@@ -294,7 +295,6 @@ class WorkOrder extends Api
|
|
|
$bomList = \db('工单_bom资料')
|
|
|
->where('BOM_工单编号',$Gd_gdbh)
|
|
|
->field($field)
|
|
|
- ->cache(true,84600)
|
|
|
->select();
|
|
|
if (!empty($bomList)){
|
|
|
foreach ($bomList as $key=>$value){
|
|
|
@@ -505,27 +505,40 @@ class WorkOrder extends Api
|
|
|
{
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+ $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
|
|
|
+ if ($lastId<10000000){
|
|
|
+ $lastId = 10000000;
|
|
|
+ }else{
|
|
|
+ $lastId = $lastId + 1;
|
|
|
+ }
|
|
|
//获取原工单工艺资料
|
|
|
- $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
|
|
|
+ $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->select();
|
|
|
$ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
|
|
|
foreach ($oldProcessData as $k=>$v){
|
|
|
- $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
|
|
|
+ $oldProcessData[$k]['Gy0_gdbh'] = $oldWorkOrder;
|
|
|
$oldProcessData[$k]['Sys_id'] = '';
|
|
|
- $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
|
|
|
+ $oldProcessData[$k]['UniqId'] = $lastId + $k;
|
|
|
+ $oldProcessData[$k]['PD_WG'] = '1900-01-01 00:00:00';
|
|
|
}
|
|
|
- if (\db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
|
|
|
- \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
|
|
|
+ if (\db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->find()){
|
|
|
+ \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->delete();
|
|
|
}
|
|
|
//获取原工单印件资料
|
|
|
- $oldPrintData = \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->select();
|
|
|
+ $lastUniqId = \db('工单_印件资料')->order('UniqId desc')->value('UniqId');
|
|
|
+ if ($lastUniqId<1000000){
|
|
|
+ $lastUniqId = 1000000;
|
|
|
+ }else{
|
|
|
+ $lastUniqId = $lastUniqId + 1;
|
|
|
+ }
|
|
|
+ $oldPrintData = \db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->select();
|
|
|
$PrintUniqId = \db('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
|
|
|
foreach ($oldPrintData as $k=>$v){
|
|
|
- $oldPrintData[$k]['Yj_Gdbh'] = $newWorkOrder;
|
|
|
+ $oldPrintData[$k]['Yj_Gdbh'] = $oldWorkOrder;
|
|
|
$oldPrintData[$k]['Sys_id'] = '';
|
|
|
- $oldPrintData[$k]['Uniqid'] = $PrintUniqId['Uniqid'] +$k +1;
|
|
|
+ $oldPrintData[$k]['Uniqid'] = $lastUniqId +$k +1;
|
|
|
}
|
|
|
- if (\db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->find()){
|
|
|
- \db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->delete();
|
|
|
+ if (\db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->find()){
|
|
|
+ \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->delete();
|
|
|
}
|
|
|
//复制印件、工艺资料
|
|
|
$ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
|
|
|
@@ -1464,18 +1477,90 @@ class WorkOrder extends Api
|
|
|
$this->success('成功',$list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增印件资料->印件资料添加
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function PrintDetailAdd()
|
|
|
+ {
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = Request::instance()->post();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
|
|
|
+ if ($lastId<1000000){
|
|
|
+ $lastId = 1000000;
|
|
|
+ }else{
|
|
|
+ $lastId = $lastId + 1;
|
|
|
+ }
|
|
|
+ $param['Uniqid'] = $lastId;
|
|
|
+ $param['Sys_rq'] = date('Y-m-d H:i:s',time());
|
|
|
+ $param['Mod_rq'] = date('Y-m-d H:i:s',time());
|
|
|
+ $sql = \db('工单_印件资料')->fetchSql(true)->insert($param);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res !== false){
|
|
|
+ $this->success('成功');
|
|
|
+ }else{
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //新增工艺资料->工艺资料添加
|
|
|
+
|
|
|
+ public function ProcessDetailAdd()
|
|
|
+ {
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = Request::instance()->post();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
|
|
|
+ if ($lastId<100000000){
|
|
|
+ $lastId = 100000000;
|
|
|
+ }else{
|
|
|
+ $lastId = $lastId + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增工艺资料->印件编号获取
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function PrintDetailList()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $printList = \db('工单_印件资料')
|
|
|
+ ->where('Yj_Gdbh',$param['workOrder'])
|
|
|
+ ->order('yj_Yjno')
|
|
|
+ ->select();
|
|
|
+ if (empty($printList)){
|
|
|
+ $this->success('未找到该工单印件资料');
|
|
|
+ }
|
|
|
+ $list = [];
|
|
|
+ foreach ($printList as $key=>$value){
|
|
|
+ $list[$key]['name'] = rtrim($value['yj_Yjno']).'-->'.rtrim($value['yj_yjmc']);
|
|
|
+ $list[$key]['no'] = rtrim($value['yj_Yjno']);
|
|
|
+ }
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
|
|
|
- //新增印件资料->印件资料添加
|
|
|
|
|
|
-// public function PrintDetailAdd()
|
|
|
-// {
|
|
|
-// if (Request::instance()->isPost() === false){
|
|
|
-// $this->error('请求错误');
|
|
|
-// }
|
|
|
-// $param = Request::instance()->post();
|
|
|
-// if (empty($param)){
|
|
|
-// $this->error('参数错误');
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
}
|