|
|
@@ -1,1566 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace app\api\controller;
|
|
|
-
|
|
|
-
|
|
|
-use app\common\controller\Api;
|
|
|
-use Monolog\Handler\IFTTTHandler;
|
|
|
-use think\Db;
|
|
|
-use think\Request;
|
|
|
-
|
|
|
-/**
|
|
|
- * 工单资料管理
|
|
|
- */
|
|
|
-class WorkOrder extends Api
|
|
|
-{
|
|
|
- protected $noNeedLogin = ['*'];
|
|
|
- protected $noNeedRight = ['*'];
|
|
|
-
|
|
|
- /**
|
|
|
- * 工单资料菜单列表
|
|
|
- *
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @return false|string
|
|
|
- * @throws \think\Exception
|
|
|
- */
|
|
|
- public function DataList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- //获取总计划中数量和总生产中数量
|
|
|
- $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
|
|
|
- $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
|
|
|
- $data = [
|
|
|
- 'productingAll' => $productingAll,
|
|
|
- 'progressAll' => $progressAll
|
|
|
- ];
|
|
|
-// $sql = "SELECT
|
|
|
-// SUBSTRING( `成品代号`, 1, 4 ) AS prefix,
|
|
|
-// rtrim( Gd_khmc ) AS khmc,
|
|
|
-// RTRIM( `Gd_客户名称` ) AS 客户名称
|
|
|
-// FROM
|
|
|
-// `工单_基本资料`
|
|
|
-// WHERE
|
|
|
-// `成品代号` <> ''
|
|
|
-// AND ( `Gd_客户名称` <> '' OR Gd_khmc <> '' )
|
|
|
-// GROUP BY
|
|
|
-// prefix
|
|
|
-// ORDER BY
|
|
|
-// prefix";
|
|
|
- $sql = "SELECT DISTINCT
|
|
|
- (客户编号),rtrim(客户名称 ) as 客户名称
|
|
|
- FROM
|
|
|
- `产品_基本资料`
|
|
|
- GROUP BY
|
|
|
- 客户编号
|
|
|
- order by
|
|
|
- 客户编号";
|
|
|
- $list = \db()->query($sql);
|
|
|
- if (empty($list)){
|
|
|
- $this->success('',[]);
|
|
|
- }
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $value['客户编号'] = rtrim($value['客户编号']);
|
|
|
- if ($value['客户编号'] == '1098'){
|
|
|
- $value['客户名称'] = '打样专用';
|
|
|
- }
|
|
|
- //这条sql查出来的数据可能不对,试一下以下sql
|
|
|
- //SELECT COUNT(*) FROM `工单_基本资料` WHERE (SUBSTRING( `成品代号`, 1, 4 ) = '1001' OR (`Gd_客户名称`='浙江中烟' AND `Gd_客户代号` = '1001')) AND gd_statu = '2-生产中' AND `行号` = '1'
|
|
|
- $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
|
|
|
- $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
|
|
|
- $string = '';
|
|
|
- if ($productIng != 0){
|
|
|
- $string = $string."生产中:".$productIng;
|
|
|
- }
|
|
|
- if ($proGress != 0){
|
|
|
- $string = $string."计划中:".$proGress;
|
|
|
- }
|
|
|
- if ($string !== ''){
|
|
|
-// $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
- $data[$key] = $value['客户编号'].'【'.$string.'】'.$value['客户名称'];
|
|
|
- }else{
|
|
|
-// $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
|
|
|
- $data[$key] = $value['客户编号'].$value['客户名称'];
|
|
|
- }
|
|
|
- }
|
|
|
- $this->success('成功',$data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工单基本资料列表
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $limit 查询长度
|
|
|
- * @param string $Gd_khdh 客户代号
|
|
|
- * @param string $startTime 接单日期开始时间
|
|
|
- * @param string $endTime 接单日期结束时间
|
|
|
- * @return \think\response\Json
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function WorkList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $search = input('search');
|
|
|
- $clientNumber = input('Gd_khdh');
|
|
|
- $startTime = input('start');
|
|
|
- $endTime = input('end');
|
|
|
- $page = input('page');
|
|
|
- $limit = input('limit');
|
|
|
- $where = [];
|
|
|
- if (!empty($clientNumber)){
|
|
|
- $where['成品代号'] = ['like',$clientNumber.'%'];
|
|
|
- }
|
|
|
- if (!empty($workOrder)){
|
|
|
- $where['Gd_gdbh'] = $workOrder;
|
|
|
- }
|
|
|
- if (!empty($productCode)){
|
|
|
- $where['Gd_cpdh'] = $productCode;
|
|
|
- }
|
|
|
- if (!empty($search)){
|
|
|
- $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$search.'%'];
|
|
|
- }
|
|
|
- if (!empty($startTime) && !empty($endTime)){
|
|
|
- $where['接单日期'] = ['between',[$startTime,$endTime]];
|
|
|
- }
|
|
|
- $total = \db('工单_基本资料')->where($where)->count();
|
|
|
- $list = \db('工单_基本资料')
|
|
|
- ->where($where)
|
|
|
- ->order('Gd_statu desc')
|
|
|
- ->limit(($page-1)*$limit,$limit)
|
|
|
- ->select();
|
|
|
- //工单基本资料数据整理
|
|
|
- $data = [];
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $data[$key] = [
|
|
|
- '工单编号' => rtrim($value['Gd_gdbh']),
|
|
|
- '生产分类' => rtrim($value['Gd_生产分类']),
|
|
|
- '销售订单号' => rtrim($value['销售订单号']),
|
|
|
- '产品代号' => rtrim($value['Gd_cpdh']),
|
|
|
- '产品名称' => rtrim($value['Gd_cpmc']),
|
|
|
- '订单数量' => rtrim($value['订单数量']),
|
|
|
- '单位' => rtrim($value['计量单位']),
|
|
|
- '折合大箱' => rtrim((int)$value['投料大箱']),
|
|
|
- '投料率' => rtrim($value['投料率']),
|
|
|
- '平均合格率' => '',
|
|
|
- '开单日期' => date('Y-m-d',strtotime(rtrim($value['接单日期']))),
|
|
|
- '交货日期' => date('Y-m-d',strtotime(rtrim($value['交货日期']))),
|
|
|
- '工单类型' => rtrim($value['Gd_lx']),
|
|
|
- '工单状态' => rtrim($value['gd_statu']),
|
|
|
- '当前生产工序' => '',
|
|
|
- '产量提交时间' => '',
|
|
|
- '建档用户' => rtrim($value['Sys_id']),
|
|
|
- '建档时间' => rtrim($value['Sys_rq']),
|
|
|
- '更新时间' => rtrim($value['Mod_rq']),
|
|
|
- 'Uniqid' => rtrim($value['Uniqid'])
|
|
|
- ];
|
|
|
- $number = \db('工单_工艺资料')->where('Gy0_gdbh',$data[$key]['工单编号'])->count();
|
|
|
- if ($number === 0){
|
|
|
- $data[$key]['status'] = '*';
|
|
|
- }else{
|
|
|
- $data[$key]['status'] = '';
|
|
|
- }
|
|
|
- }
|
|
|
- $this->success('成功',['data'=>$data,'total'=>$total]);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工单详情
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function workOrderListDetail()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $Gd_gdbh = input('Gd_gdbh');
|
|
|
- if (empty($Gd_gdbh)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = [];
|
|
|
- //印件资料
|
|
|
- $printList = \db('工单_印件资料')
|
|
|
- ->where('Yj_Gdbh',$Gd_gdbh)
|
|
|
-// ->cache(true,84600)
|
|
|
- ->select();
|
|
|
- if (!empty($printList)){
|
|
|
- foreach ($printList as $key=>$value){
|
|
|
- $data['printList'][$key] = [
|
|
|
- '印件号' => rtrim($value['yj_Yjno']),
|
|
|
- '印件代号' => rtrim($value['yj_Yjdh']),
|
|
|
- '印件名称' => rtrim($value['yj_yjmc']),
|
|
|
- '纸张代号' => rtrim($value['yj_zzdh']),
|
|
|
- '纸张名称' => rtrim($value['yj_zzmc']),
|
|
|
- '投料规格' => rtrim($value['yj_tlgg']),
|
|
|
- '平张投料' => rtrim($value['yj_平张投料']),
|
|
|
- '开料规格' => rtrim($value['yj_klgg']),
|
|
|
- '开数*联数' => rtrim($value['yj_ks']).'*'.rtrim($value['yj_ls']),
|
|
|
- '建档用户' => rtrim($value['Sys_id']),
|
|
|
- '建档时间' => rtrim($value['Sys_rq']),
|
|
|
- '更新时间' => rtrim($value['Mod_rq']),
|
|
|
- 'zzdh1' => rtrim($value['yj_zzdh1']),
|
|
|
- 'zzdh2' => rtrim($value['yj_zzdh2']),
|
|
|
- 'zzdh3' => rtrim($value['yj_zzdh3']),
|
|
|
- 'zzdh4' => rtrim($value['yj_zzdh4']),
|
|
|
- 'zzmc1' => rtrim($value['yj_zzmc1']),
|
|
|
- 'zzmc2' => rtrim($value['yj_zzmc2']),
|
|
|
- 'zzmc3' => rtrim($value['yj_zzmc3']),
|
|
|
- 'zzmc4' => rtrim($value['yj_zzmc4']),
|
|
|
- '订单数量' => rtrim($value['yj_成品数量']),
|
|
|
- '万小张' => rtrim($value['yj_实际投料']),
|
|
|
- '开数' => rtrim($value['yj_ks']),
|
|
|
- '联数' => rtrim($value['yj_ls']),
|
|
|
- '核算规格' => rtrim($value['Yj_核算规格']),
|
|
|
- '备注' => rtrim($value['yj_desc']),
|
|
|
- 'Uniqid' => rtrim($value['Uniqid'])
|
|
|
- ];
|
|
|
- }
|
|
|
- }else{
|
|
|
- $data['printList'] = [];
|
|
|
- }
|
|
|
-
|
|
|
- //工艺资料
|
|
|
- $processList = \db('工单_工艺资料')
|
|
|
- ->where('Gy0_gdbh',$Gd_gdbh)
|
|
|
-// ->cache(true,84600)
|
|
|
- ->select();
|
|
|
- if (!empty($processList)){
|
|
|
- foreach ($processList as $key=>$value){
|
|
|
- if ($value['Gy0_yjno']<10){
|
|
|
- $value['Gy0_yjno'] = '0'.$value['Gy0_yjno'];
|
|
|
- }
|
|
|
- if ($value['Gy0_gxh']<10){
|
|
|
- $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']);
|
|
|
- }
|
|
|
- $number = round(($scrap/((int)($value['Gy0_计划接货数']/$value['Gy0_ls'])))*100,2).'%';
|
|
|
- if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
|
|
|
- $status = '已完工';
|
|
|
- }else{
|
|
|
- $status = '未完工';
|
|
|
- }
|
|
|
- $data['processList'][$key] = [
|
|
|
- '重点工序' => rtrim($value['重点工序']),
|
|
|
- '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
|
|
|
- '备选工序' => rtrim($value['备选工序']),
|
|
|
- '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
|
|
|
- '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
|
|
|
- '基础损耗' => rtrim($value['Gy0_Rate0']),
|
|
|
- '损耗率' => rtrim($value['Gy0_Rate1']),
|
|
|
- '报废定额' => $scrap,
|
|
|
- '允损比例' => $number,
|
|
|
- '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
|
|
|
- '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
|
|
|
- '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
|
|
|
- '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
|
|
|
- '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
|
|
|
- '机检_次品板' => (int)$value['机检_次品板']=0?'':$value['机检_次品板'],
|
|
|
- '机检_废检' => (int)$value['机检_废检']=0?'':$value['机检_废检'],
|
|
|
- '开数*联数' => rtrim($value['Gy0_ks']).'*'.rtrim($value['Gy0_ls']),
|
|
|
- '备注' => isset($value['工序备注'])?rtrim($value['工序备注']):'',
|
|
|
- '印刷方式' => isset($value['印刷方式'])?rtrim($value['印刷方式']):'',
|
|
|
- '版距' => isset($value['版距'])?rtrim($value['版距']):'',
|
|
|
- '建档用户' => rtrim($value['Sys_id']),
|
|
|
- '建档日期' => isset($value['Sys_rq'])?rtrim($value['Sys_rq']):'',
|
|
|
- '更新时间' => isset($value['Mod_rq'])?rtrim($value['Mod_rq']):'',
|
|
|
- '车间名称' => rtrim($value['Gy0_SITE']),
|
|
|
- '质量要求' => rtrim($value['质量要求']),
|
|
|
- '质量隐患' => rtrim($value['质量隐患']),
|
|
|
- '开数' => rtrim($value['Gy0_ks']),
|
|
|
- '联数' => rtrim($value['Gy0_ls']),
|
|
|
- 'UniqId' => rtrim($value['UniqId']),
|
|
|
- 'shdh' => rtrim($value['Gy0_shdh']),
|
|
|
- '辅助工时' => rtrim($value['Gy0_辅助工时']),
|
|
|
- '小时产能' => rtrim($value['Gy0_小时产能']),
|
|
|
- 'status' => $status
|
|
|
- ];
|
|
|
- }
|
|
|
- }else{
|
|
|
- $data['processList'] = [];
|
|
|
- }
|
|
|
-
|
|
|
- //BOM资料
|
|
|
- $field = 'rtrim(BOM_方案) as 方案,rtrim(BOM_物料编码) as 物料编号,rtrim(BOM_物料名称) as 物料名称,BOM_投料单位,
|
|
|
- BOM_投入数,BOM_产出数,BOM_产出单位,rtrim(BOM_计划用量) as 计划用量,rtrim(Sys_ID) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
|
|
|
- $bomList = \db('工单_bom资料')
|
|
|
- ->where('BOM_工单编号',$Gd_gdbh)
|
|
|
- ->field($field)
|
|
|
- ->select();
|
|
|
- if (!empty($bomList)){
|
|
|
- foreach ($bomList as $key=>$value){
|
|
|
- $bomList[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
|
|
|
- unset($bomList[$key]['BOM_投料单位'],$bomList[$key]['BOM_投入数'],$bomList[$key]['BOM_产出数'],$bomList[$key]['BOM_产出单位']);
|
|
|
- $bomList[$key]['计划用量'] = rtrim((float)$value['计划用量']);
|
|
|
- }
|
|
|
- $data['BOM'] = $bomList;
|
|
|
- }else{
|
|
|
- $data['BOM'] = [];
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('成功',$data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑页面展示
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function DataCorrection()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('Gd_gdbh');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $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(计量单位) 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';
|
|
|
- $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
|
|
|
- if (empty($list)){
|
|
|
- $this->error('未找到该工单信息');
|
|
|
- }
|
|
|
- $printData = \db('工单_印件资料')
|
|
|
- ->where('Yj_Gdbh',$workOrder)
|
|
|
- ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料,rtrim(Uniqid) as id')
|
|
|
- ->cache(true,84600)
|
|
|
- ->find();
|
|
|
- if (empty($printData)){
|
|
|
- $this->error('未找到该工单印件资料');
|
|
|
- }
|
|
|
- $list['印件名称'] = $printData['印件名称'];
|
|
|
- $list['印件代号'] = $printData['印件代号'];
|
|
|
- $list['平张投料'] = $printData['平张投料'];
|
|
|
- $list['印件ID'] = $printData['id'];
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工单资料修改
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
-
|
|
|
- public function WorkOrderEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param) || isset($param['Uniqid']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $row = [
|
|
|
- 'Gd_lx' => isset($param['lx'])?$param['lx']:'',
|
|
|
- '开单日期' => isset($param['kdrq'])?$param['kdrq']:'',
|
|
|
- 'Gd_gdbh' => isset($param['gdbh'])?$param['gdbh']:'',
|
|
|
- 'Gd_生产分类' => isset($param['scfl'])?$param['scfl']:'',
|
|
|
- 'Gd_客户代号' => isset($param['khdh'])?$param['khdh']:'',
|
|
|
- 'Gd_客户名称' => isset($param['khmc'])?$param['khmc']:'',
|
|
|
- '成品代号' => isset($param['cpdh'])?$param['cpdh']:'',
|
|
|
- '成品名称' => isset($param['cpmc'])?$param['cpmc']:'',
|
|
|
- '订单数量' => isset($param['ddsl'])?$param['ddsl']:'',
|
|
|
- '交货日期' => isset($param['jhrq'])?$param['jhrq']:'',
|
|
|
- '投料率' => isset($param['tll'])?$param['tll']:'',
|
|
|
- '计划投料' => isset($param['jhtl'])?$param['jhtl']:'',
|
|
|
- '实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
|
|
|
- '计量单位' => isset($param['jldw'])?$param['jldw']:'',
|
|
|
- '投料大箱' => isset($param['tldx'])?$param['tldx']:'',
|
|
|
- '销售订单号' => isset($param['xsddh'])?$param['xsddh']:'',
|
|
|
- '警语版面' => isset($param['jymb'])?$param['jymb']:'',
|
|
|
- '产品版本号' => isset($param['bbh'])?$param['bbh']:'',
|
|
|
- '客户ERP编码' => isset($param['erp'])?$param['erp']:'',
|
|
|
- '码源数量' => isset($param['ymsl'])?$param['ymsl']:'',
|
|
|
- '进程备注' => isset($param['jcbz'])?$param['jcbz']:'',
|
|
|
- 'Gd_desc' => isset($param['desc'])?$param['desc']:'',
|
|
|
- '排产时库存' => isset($param['kc'])?$param['kc']:'',
|
|
|
- '平均合格率' => isset($param['avg'])?$param['avg']:'',
|
|
|
- ];
|
|
|
- $sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
|
|
|
- $res = Db::query($sql);
|
|
|
- $printSql = \db('工单_印件资料')
|
|
|
- ->where('Uniqid',$param['printID'])
|
|
|
- ->fetchSql(true)
|
|
|
- ->update(['yj_yjmc'=>$param['yjmc'],'yj_Yjdh'=>$param['yjdh'],'yj_平张投料'=>$param['jhtl']]);
|
|
|
- $printRes = Db::query($printSql);
|
|
|
- if ($res !== false && $printRes !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * U8投料试算
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $processCode 产品编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
-
|
|
|
- public function U8Trial()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false)
|
|
|
- {
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $productCode = input('productCode');
|
|
|
- if (empty($productCode)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $field = 'rtrim(Gy0_cpdh) as 产品代号,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
- rtrim(Gy0_Ms) as 墨色数,rtrim(Gy0_shdh) as 损耗代号,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as 加工联数';
|
|
|
- $list = \db('产品_工艺资料')->where('Gy0_cpdh',$productCode)->field($field)->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到该产品工序');
|
|
|
- }
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $data = \db('dic_lzsh')->where('sys_bh',$value['损耗代号'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->cache(true)->find();
|
|
|
- $list[$key]['调机损耗'] = isset($data['rate0'])?$data['rate0']:'';
|
|
|
- $list[$key]['运行损耗率'] = isset($data['rate1'])?$data['rate1']:'';
|
|
|
- if ($value['add_gxmc'] !== ''){
|
|
|
- $list[$key]['工序名称'] = $value['gxmc'].'【'.$value['add_gxmc'].'】';
|
|
|
- }else{
|
|
|
- $list[$key]['工序名称'] = $value['gxmc'];
|
|
|
- }
|
|
|
- unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 引用产品资料->获取产品资料
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
-
|
|
|
- public function ProductInformation()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false)
|
|
|
- {
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('workOrder');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_客户名称) as 客户名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称';
|
|
|
- $Detail = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
|
|
|
- if (empty($Detail)){
|
|
|
- $this->success('未找到工单信息');
|
|
|
- }
|
|
|
- $Detail['客户代号'] = substr($Detail['产品代号'],0,4);
|
|
|
- $this->success('成功',$Detail);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 引用产品资料->复制产品工艺资料
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $oldWorkOrder 被复制工单编号
|
|
|
- * @param string $newWorkOrder 复制工单编号
|
|
|
- * @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 ProductInformationEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false)
|
|
|
- {
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $oldWorkOrder = input('oldWorkOrder');
|
|
|
- $newWorkOrder = input('newWorkOrder');
|
|
|
- if (empty($oldWorkOrder) || empty($newWorkOrder))
|
|
|
- {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
|
|
|
- if ($lastId<10000000){
|
|
|
- $lastId = 10000000;
|
|
|
- }else{
|
|
|
- $lastId = $lastId + 1;
|
|
|
- }
|
|
|
- //获取原工单工艺资料
|
|
|
- $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->select();
|
|
|
- $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
|
|
|
- foreach ($oldProcessData as $k=>$v){
|
|
|
- $oldProcessData[$k]['Gy0_gdbh'] = $oldWorkOrder;
|
|
|
- $oldProcessData[$k]['Sys_id'] = '';
|
|
|
- $oldProcessData[$k]['UniqId'] = $lastId + $k;
|
|
|
- $oldProcessData[$k]['PD_WG'] = '1900-01-01 00:00:00';
|
|
|
- }
|
|
|
- if (\db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->find()){
|
|
|
- \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->delete();
|
|
|
- }
|
|
|
- //获取原工单印件资料
|
|
|
- $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'] = $oldWorkOrder;
|
|
|
- $oldPrintData[$k]['Sys_id'] = '';
|
|
|
- $oldPrintData[$k]['Uniqid'] = $lastUniqId +$k +1;
|
|
|
- }
|
|
|
- if (\db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->find()){
|
|
|
- \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->delete();
|
|
|
- }
|
|
|
- //复制印件、工艺资料
|
|
|
- $ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
|
|
|
- $ProcessRes = Db::query($ProcessSQL);
|
|
|
- $PrintSQL = \db('工单_印件资料')->fetchSql(true)->insertAll($oldPrintData);
|
|
|
- $PrintRes = Db::query($PrintSQL);
|
|
|
- if ($ProcessRes !== false && $PrintRes !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 工艺流程调成->获取当前工单工艺资料
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workorder 当前工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function ProcessFlow()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('workOrder');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到工单信息');
|
|
|
- }
|
|
|
- $filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
- rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
|
|
|
- rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间,rtrim(UniqId) as UniqId';
|
|
|
- $process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
|
|
|
- if (empty($process)){
|
|
|
- $this->error('未找到该工单工艺资料');
|
|
|
- }
|
|
|
- foreach ($process as $key=>$value){
|
|
|
- if (isset($value['add_gxmc'])){
|
|
|
- $process[$key]['工序名称'] = $value['gxmc'] . '【'.$value['add_gxmc'].'】';
|
|
|
- }else{
|
|
|
- $process[$key]['工序名称'] = $value['gxmc'];
|
|
|
- }
|
|
|
- $process[$key]['工价系数'] = (float)$value['工价系数'];
|
|
|
- $process[$key]['损耗系数'] = (float)$value['损耗系数'];
|
|
|
- $process[$key]['开数*联数'] = $value['ks'].'*'.$value['ls'];
|
|
|
- }
|
|
|
- $list['process'] = $process;
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 参照工单列表获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @param string $productCode 产品代号
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function ReferenceWorkOrder()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $productCode = input('productCode');
|
|
|
- $workOrder = input('workOrder');
|
|
|
- if (empty($productCode) || empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('工单_基本资料')->where('成品代号',$productCode)->distinct(true)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未获取该产品其他工单信息');
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工艺资料复制
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $oldWorkOrder 被复制工单编号
|
|
|
- * @param string $newWorkOrder 复制工单编号
|
|
|
- * @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 ProcessCopy()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $UniqId = [];
|
|
|
- $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
|
|
|
- if ($lastId['id']>10000000){
|
|
|
- $lastUniqId = $lastId['id'];
|
|
|
- }else{
|
|
|
- $lastUniqId = 10000000;
|
|
|
- }
|
|
|
- foreach ($param as $key=>$value){
|
|
|
- $UniqId[$key] = $value['UniqId'];
|
|
|
- }
|
|
|
- $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
|
|
|
- if (empty($processList)){
|
|
|
- $this->success('未找到工艺资料');
|
|
|
- }
|
|
|
- $data = [];
|
|
|
- foreach ($param as $key=>$value){
|
|
|
- foreach ($processList as $k=>$v){
|
|
|
- if ($value['UniqId'] = $v['UniqId']){
|
|
|
- $data[$key] = $v;
|
|
|
- $data[$key]['Gy0_gxh'] = $value['gxh'];
|
|
|
- $data[$key]['Gy0_gdbh'] = $value['workOrder'];
|
|
|
- $data[$key]['UniqId'] = $lastUniqId + $key + 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
|
|
|
- if ($res !== false){
|
|
|
- $result = \db('工单_工艺资料')->insertAll($data);
|
|
|
- if ($result !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * U8工单列表
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function U8workOrder()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $filed = 'rtrim(Gd_gdbh) as 工单编号,rtrim(行号) as 行号,rtrim(Gd_客户代号) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
|
|
|
- rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(Mod_rq) as 获取日期,rtrim(Uniqid) as 序号';
|
|
|
- $list = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field($filed)->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到工单');
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * U8工单资料删除
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function U8DataCorrection()
|
|
|
- {
|
|
|
- if($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('Uniqid');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = [];
|
|
|
- if (strpos($workOrder,',')){
|
|
|
- $data = explode(',',$workOrder);
|
|
|
- }else{
|
|
|
- $data[0] = $workOrder;
|
|
|
- }
|
|
|
- $res = \db('工单_基本资料')->where('Uniqid','in',$data)->delete();
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 产品废检系数调整->质检工艺数据获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function TestCoefficient()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('workOrder');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $where = [
|
|
|
- 'Gy0_gdbh' => $workOrder,
|
|
|
- 'Gy0_gxmc' => ['like','%检%']
|
|
|
- ];
|
|
|
- $filed = 'rtrim(Gy0_gdbh) as gdbh,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(人工检_正品板) as 人工正品板,
|
|
|
- rtrim(人工检_次品板) as 人工次品板,rtrim(人工检_废检) as 人工废检,rtrim(机检_正品板) as 机检正品板,rtrim(机检_次品板) as 机检次品板,
|
|
|
- rtrim(机检_废检) as 机检废检,rtrim(Gy0_sbbh) as 设备编号,rtrim(Uniqid) as Uniqid';
|
|
|
- $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到该工单工艺');
|
|
|
- }
|
|
|
- $name = \db('工单_基本资料')
|
|
|
- ->where('Gd_gdbh',$workOrder)
|
|
|
- ->field('rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_khmc) as 客户名称,rtrim(Gd_cpmc) as 产品名称')
|
|
|
- ->find();
|
|
|
- if (empty($name)){
|
|
|
- $this->success('未找到该工单');
|
|
|
- }
|
|
|
- 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['gdbh'].'-'.$value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
|
|
|
- unset($list[$key]['gdbh'],$list[$key]['yjno'],$list[$key]['gxmc']);
|
|
|
- $list[$key]['产品编号'] = $name['产品代号'];
|
|
|
- $list[$key]['产品名称'] = $name['产品名称'];
|
|
|
- $list[$key]['客户名称'] = $name['客户名称'];
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 产品质检系数调整->系数修改
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workorder 工单编号
|
|
|
- * @param string $processCode 工序号
|
|
|
- * @param float $code1 人工正品板
|
|
|
- * @param float $code2 人工次品板
|
|
|
- * @param float $code3 人工废检
|
|
|
- * @param float $code4 机检正品板
|
|
|
- * @param float $code5 机检次品板
|
|
|
- * @param float $code6 机检废检
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function TestCoefficientEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('workOrder');
|
|
|
- $processCode = input('processCode');
|
|
|
- $row = [
|
|
|
- '人工检_正品板' => input('code1'),
|
|
|
- '人工检_次品板' => input('code2'),
|
|
|
- '人工检_废检' => input('code3'),
|
|
|
- '机检_正品板' => input('code4'),
|
|
|
- '机检_次品板' => input('code5'),
|
|
|
- '机检_废检' => input('code6'),
|
|
|
- ];
|
|
|
- if (empty($workOrder) || empty($processCode)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $where = [
|
|
|
- 'Gy0_gdbh' => $workOrder,
|
|
|
- 'Gy0_gxh' => $processCode
|
|
|
- ];
|
|
|
- $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update($row);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 修正工单核算参数->数据获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param string $workOrder 工单编号
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function AccountingParameter()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $workOrder = input('workOrder');
|
|
|
- if (empty($workOrder)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $field = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
- rtrim(Gy0_sbbh) as 参照设备,rtrim(工价系数) as 难度系数,rtrim(Gy0_shdh) as 损耗代号,rtrim(Gy0_Rate0) as 基础损耗,rtrim(Gy0_Rate1) as 损耗率,
|
|
|
- rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Gy0_ms) as 计损色数,rtrim(损耗系数) as 损耗系数,rtrim(UniqId) as UniqId';
|
|
|
- $list = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($field)->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到该工单工艺资料');
|
|
|
- }
|
|
|
- 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'].'('.$value['add_gxmc'].')';
|
|
|
- unset($list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 修正工单核算参数->参数修改
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param void
|
|
|
- * @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 AccountingParameterEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param) || isset($param[0]['Uniqid']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $i = 0;
|
|
|
- foreach ($param as $key=>$value){
|
|
|
- if (!empty($value['loss'])){
|
|
|
- $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
|
|
|
- }
|
|
|
- $row = [
|
|
|
- '工价系数' => $value['difficulty']?:'',
|
|
|
- 'Gy0_shdh' => $value['loss']?:'',
|
|
|
- '印刷方式' => $value['printMode']?:'',
|
|
|
- '版距' => $value['plate']?:'',
|
|
|
- 'Gy0_ms' => $value['chromatic']?:'',
|
|
|
- '损耗系数' => $value['wastage']?:'',
|
|
|
- 'Gy0_Rate0' => $data['rate0'],
|
|
|
- 'Gy0_Rate1' => $data['rate1']
|
|
|
- ];
|
|
|
- $sql = \db('工单_工艺资料')->where('Uniqid',$value['Uniqid'])->fetchSql(true)->update($row);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 印件资料修改
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
-
|
|
|
- public function PrintedEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param) || isset($param['Uniqid']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'yj_Yjno' => isset($param['yjno'])?$param['yjno']:'',
|
|
|
- 'yj_Yjdh' => isset($param['yjdh'])?$param['yjdh']:'',
|
|
|
- 'yj_yjmc' => isset($param['yjmc'])?$param['yjmc']:'',
|
|
|
- 'yj_zzdh' => isset($param['zzdh'])?$param['zzdh']:'',
|
|
|
- 'yj_zzdh1' => isset($param['zzdh1'])?$param['zzdh1']:'',
|
|
|
- 'yj_zzdh2' => isset($param['zzdh2'])?$param['zzdh2']:'',
|
|
|
- 'yj_zzdh3' => isset($param['zzdh3'])?$param['zzdh3']:'',
|
|
|
- 'yj_zzdh4' => isset($param['zzdh4'])?$param['zzdh4']:'',
|
|
|
- 'yj_zzmc' => isset($param['zzmc'])?$param['zzmc']:'',
|
|
|
- 'yj_zzmc1' => isset($param['zzmc1'])?$param['zzmc1']:'',
|
|
|
- 'yj_zzmc2' => isset($param['zzmc2'])?$param['zzmc2']:'',
|
|
|
- 'yj_zzmc3' => isset($param['zzmc3'])?$param['zzmc3']:'',
|
|
|
- 'yj_zzmc4' => isset($param['zzmc4'])?$param['zzmc4']:'',
|
|
|
- 'yj_成品数量' => isset($param['cpsl'])?$param['cpsl']:'',
|
|
|
- 'yj_实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
|
|
|
- 'yj_平张投料' => isset($param['pztl'])?$param['pztl']:'',
|
|
|
- 'yj_tlgg' => isset($param['tlgg'])?$param['tlgg']:'',
|
|
|
- 'yj_klgg' => isset($param['klgg'])?$param['klgg']:'',
|
|
|
- 'Yj_核算规格' => isset($param['hsgg'])?$param['hsgg']:'',
|
|
|
- 'yj_ks' => isset($param['ks'])?$param['ks']:'',
|
|
|
- 'yj_ls' => isset($param['ls'])?$param['ls']:'',
|
|
|
- 'yj_desc' => isset($param['desc'])?$param['desc']:'',
|
|
|
- ];
|
|
|
- $sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工艺资料修改
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param void
|
|
|
- * @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 ProcessDetailEdit()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param) || isset($param['UniqId']) === false){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $rate = \db('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
|
|
|
- $data = [
|
|
|
- '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
|
|
|
- '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
|
|
|
- 'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
|
|
|
- 'Gy0_Rate0' => isset($rate['rate0'])?$rate['rate0']:'',
|
|
|
- 'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:'',
|
|
|
- 'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
|
|
|
- '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
|
|
|
- '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
|
|
|
- 'Gy0_小时产能' => $param['xscn'],
|
|
|
- 'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
|
- ];
|
|
|
- $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- $status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
|
|
|
- if ($status['status'] !== '2-生产中'){
|
|
|
- $statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
|
|
|
- Db::query($statusSql);
|
|
|
- }
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 工艺资料编辑->机台列表获取
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function MachineList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('设备_基本资料')
|
|
|
- ->where('存放地点',$param['address'])
|
|
|
- ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
|
|
|
- ->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到该车间机台');
|
|
|
- }
|
|
|
- $data = [];
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $data[$key] = $value['设备编号'].'-->'.$value['设备名称'];
|
|
|
- }
|
|
|
- $this->success('成功',$data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 打印作业通知单->工单印件和工序获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function PrintCodeList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('工单_印件资料')
|
|
|
- ->field([
|
|
|
- 'rtrim(yj_Yjno)' => '印件号',
|
|
|
- 'rtrim(yj_yjmc)' => '印件名称'
|
|
|
- ])
|
|
|
- ->where('Yj_Gdbh',$param['workOrder'])
|
|
|
- ->select();
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 打印作业通知单->工艺编号获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function ProcessCodeList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('工单_工艺资料')
|
|
|
- ->field('rtrim(Gy0_gxh) as 工序号')
|
|
|
- ->where([
|
|
|
- 'Gy0_gdbh' => $param['workOrder'],
|
|
|
- 'Gy0_yjno' => $param['yjno']
|
|
|
- ])
|
|
|
- ->select();
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 打印作业通知单
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function PrintJobOrder()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false) {
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = $this->workOrderDetailGet($param['workOrder'],$param['yjno']);
|
|
|
- if (empty($data)){
|
|
|
- $this->success('未找到工单信息');
|
|
|
- }
|
|
|
- $materiel = $this->MaterielDetailGet($param['workOrder']);
|
|
|
- if (empty($materiel)){
|
|
|
- $this->success('未找到物料信息');
|
|
|
- }
|
|
|
- $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
|
|
|
- if (empty($printDetail)){
|
|
|
- $this->success('未找到工艺信息');
|
|
|
- }
|
|
|
- $number = 0;
|
|
|
- foreach ($printDetail as $key=>$value){
|
|
|
- $value['允损比例'] = (float)substr($value['允损比例'],0,-1);
|
|
|
- $number = $number+$value['允损比例'];
|
|
|
- }
|
|
|
- $data['制单'] = $param['PrepareDocument'];
|
|
|
- $data['审核'] = $param['examine'];
|
|
|
- $data['目标合格率'] = 100-$number.'%';
|
|
|
- $data['materiel'] = $materiel;
|
|
|
- $data['printDetail'] = $printDetail;
|
|
|
- $this->success('成功',$data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 打印作业通知单->工单及印件资料获取
|
|
|
- * @param $workOrder
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
- public function workOrderDetailGet($workOrder,$yjno)
|
|
|
- {
|
|
|
- $sql = "SELECT
|
|
|
- RTRIM( a.Gd_lx) AS 工单类型,
|
|
|
- RTRIM( a.Gd_gdbh ) AS 生产批次号,
|
|
|
- RTRIM( a.销售订单号 ) AS 销售订单号,
|
|
|
- RTRIM( a.Gd_客户代号 ) AS 客户代号,
|
|
|
- RTRIM( a.Gd_客户名称 ) AS 客户名称,
|
|
|
- RTRIM( a.成品代号 ) AS 产品代码,
|
|
|
- RTRIM( a.成品名称 ) AS 产品名称,
|
|
|
- RTRIM( a.产品版本号 ) AS 版本号,
|
|
|
- RTRIM( a.警语版面 ) AS 警语版面,
|
|
|
- RTRIM( a.码源数量 ) AS 码源数量,
|
|
|
- RTRIM( a.客户ERP编码 ) AS 客户ERP编码,
|
|
|
- RTRIM( a.接单日期 ) AS 开单日期,
|
|
|
- RTRIM( a.交货日期 ) AS 交货日期,
|
|
|
- RTRIM( a.Gd_desc ) AS 工单说明,
|
|
|
- RTRIM( a.投料率 ) AS 投料率,
|
|
|
- RTRIM( a.平均合格率 ) AS 平均合格率,
|
|
|
- RTRIM( a.投料大箱 ) AS 订货数量,
|
|
|
- RTRIM( a.排产时库存 ) AS 排产时库存,
|
|
|
- RTRIM( b.yj_Yjno ) AS 印件,
|
|
|
- RTRIM( b.yj_Yjdh ) AS 印件代号,
|
|
|
- RTRIM( b.yj_yjmc ) AS 印件名称,
|
|
|
- RTRIM( b.yj_平张投料 ) AS 平张投料量,
|
|
|
- RTRIM( b.yj_zzmc ) AS 纸张名称,
|
|
|
- RTRIM( b.yj_tlgg ) AS 投料规格,
|
|
|
- RTRIM( b.yj_ks ) AS 开数,
|
|
|
- RTRIM( b.yj_ls ) AS 联数,
|
|
|
- RTRIM( b.yj_desc ) AS 印件备注
|
|
|
- FROM
|
|
|
- `工单_基本资料` AS a
|
|
|
- JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh
|
|
|
- WHERE
|
|
|
- a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1 AND b.yj_Yjno = '{$yjno}'";
|
|
|
- $list = Db::query($sql);
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到订单数据');
|
|
|
- }
|
|
|
- $list[0]['开单日期'] = date('Y-m-d',strtotime($list[0]['开单日期']));
|
|
|
- $list[0]['交货日期'] = date('Y-m-d',strtotime($list[0]['交货日期']));
|
|
|
- $list[0]['订货数量'] = (int)$list[0]['订货数量'];
|
|
|
- $list[0]['联数'] = (int)$list[0]['联数'];
|
|
|
- $list[0]['印件代号及名称'] = $list[0]['印件代号'].' '.$list[0]['印件名称'];
|
|
|
- $list[0]['投料数量'] = $list[0]['订货数量'];
|
|
|
- unset($list[0]['印件代号'],$list[0]['印件名称']);
|
|
|
- return($list[0]);
|
|
|
- }
|
|
|
-
|
|
|
- /**打印作业流程单->物料资料获取
|
|
|
- * @param $workOrder
|
|
|
- * @return bool|\PDOStatement|string|\think\Collection
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function MaterielDetailGet($workOrder)
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'BOM_工单编号' => $workOrder,
|
|
|
- ];
|
|
|
- $filed = 'rtrim(BOM_物料编码) as 物料编码,rtrim(BOM_物料名称) as 物料名称,rtrim(BOM_投料单位) as 投料单位,rtrim(BOM_计划用量) as 计划用量';
|
|
|
- $list = \db('工单_bom资料')->where($where)->field($filed)->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到物料资料信息');
|
|
|
- }
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
|
|
|
- $list[$key]['计划用量'] = (float)$value['计划用量'];
|
|
|
- unset($list[$key]['物料编码'],$list[$key]['物料名称']);
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 打印作业流程单->工艺资料获取
|
|
|
- * @param $workOrder
|
|
|
- * @return bool|\PDOStatement|string|\think\Collection
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function PrintDetailGet($workOrder,$yjno,$gxh)
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'Gy0_gdbh' => $workOrder,
|
|
|
- 'Gy0_yjno' => $yjno,
|
|
|
- 'Gy0_gxh' => ['<=',$gxh]
|
|
|
- ];
|
|
|
- $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
|
|
|
- rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
|
|
|
- rtrim(Gy0_辅助工时) as 装版工时,rtrim(Gy0_小时产能) as 小时定额,rtrim(Gy0_生产工时) as 生产工时,rtrim(工序备注) as 工序备注';
|
|
|
- $list = \db('工单_工艺资料')
|
|
|
- ->where($where)
|
|
|
- ->field($filed)
|
|
|
- ->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('工单工艺为空');
|
|
|
- }
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- if ($value['yjno']<10){
|
|
|
- $value['yjno'] = '0'.$value['yjno'];
|
|
|
- }
|
|
|
- if ($value['gxh']<10){
|
|
|
- $value['gxh'] = '0'.$value['gxh'];
|
|
|
- }
|
|
|
- if ($value['add_gxmc'] !== null){
|
|
|
-
|
|
|
- $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
|
|
|
- }else{
|
|
|
- $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
|
|
|
- }
|
|
|
- $list[$key]['转序数'] = (int)($value['计划接货数']/$value['ls']);
|
|
|
- $list[$key]['报废定额'] = (int)($value['计划损耗']/$value['ls']);
|
|
|
- $list[$key]['允损比例'] = round(($value['计划损耗']/$value['计划接货数'])*100,2).'%';
|
|
|
- unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc'],$list[$key]['计划接货数'],$list[$key]['计划损耗']);
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取小时产能
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
-
|
|
|
- public function capacityList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $machine = explode(' ',$param['machine'])[0];
|
|
|
- $number = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(排单小时定额) as 小时产能')->find();
|
|
|
- if (empty($number)){
|
|
|
- $this->error('未找到小时产能');
|
|
|
- }
|
|
|
- $this->success('成功',$number['小时产能']);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增工单->添加工单
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param
|
|
|
- * @return void
|
|
|
- * @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 WorkOrderAdd()
|
|
|
- {
|
|
|
- if (Request::instance()->isPost() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = Request::instance()->post();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
|
|
|
- $productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
|
|
|
- $lastId = \db('工单_基本资料')->order('Uniqid desc')->value('Uniqid');
|
|
|
- if ($lastId<1000000000){
|
|
|
- $lastId = 1000000000;
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'Gd_lx' =>$param['zdgd'],
|
|
|
- 'Gd_生产分类' =>$param['sclx'],
|
|
|
- '成本处理类别' =>'',
|
|
|
- 'Gd_gdbh' =>$param['gdbh'],
|
|
|
- '行号' =>$num+1 ,
|
|
|
- 'Gd_客户代号' =>$param['khdh'],
|
|
|
- 'Gd_客户名称' =>$param['khmc'],
|
|
|
- 'Gd_khdh' =>$param['khdh'],
|
|
|
- 'Gd_khmc' =>$param['khmc'],
|
|
|
- '客户料号' =>rtrim($productDetail['客户料号']),
|
|
|
- '客户ERP编码' =>$param['erp'],
|
|
|
- 'Gd_cpdh' =>$param['cpdh'],
|
|
|
- 'Gd_cpmc' =>$param['cpmc'],
|
|
|
- '成品代号' =>$param['cpdh'],
|
|
|
- '成品名称' =>$param['cpmc'],
|
|
|
- '产品版本号' =>$param['bbh'],
|
|
|
- '销售订单号' =>$param['xsddh'],
|
|
|
- '警语版面' =>$param['jybm'],
|
|
|
- '码源数量' =>$param['mysl'],
|
|
|
- '排产时库存' =>$param['kcdx'],
|
|
|
- '投料大箱' =>$param['tldx'],
|
|
|
- '投料率' =>$param['tll'],
|
|
|
- '平均合格率' =>$param['hgl'],
|
|
|
- '进程备注' =>$param['jcbz'],
|
|
|
- 'Gd_desc' =>$param['remark'],
|
|
|
- '开单日期' =>date('Y-m-d H:i:s',time()),
|
|
|
- '接单日期' =>$param['start'],
|
|
|
- '交货日期' =>$param['end'],
|
|
|
- '订单数量' =>$param['number'],
|
|
|
- '计量单位' =>$param['tldw'],
|
|
|
- '计划投料' =>$param['pztl'],
|
|
|
- '实际投料' =>$param['wxz'],
|
|
|
- '产品单价' =>0,
|
|
|
- '入仓日期' =>'1900-01-01 00:00:00',
|
|
|
- '工单入仓数量' =>0,
|
|
|
- '工单制程废品' => 0,
|
|
|
- '工单质检废品' => 0,
|
|
|
- '工单无形损' => 0,
|
|
|
- '工单计划损耗' => 0,
|
|
|
- '工单完工日期' => $param['end'],
|
|
|
- '投料确认' => '',
|
|
|
- 'gd_statu' => '3-计划中',
|
|
|
- '直接人工' => 0,
|
|
|
- '分摊人工' => 0,
|
|
|
- '直接材料' => 0,
|
|
|
- '考核直接材料' => 0,
|
|
|
- '分摊材料' => 0,
|
|
|
- '考核分摊材料' => 0,
|
|
|
- '直接折旧' => 0,
|
|
|
- '水电气费' => 0,
|
|
|
- '分摊空调' => 0,
|
|
|
- '分摊锅炉' => 0,
|
|
|
- '分摊废气处理' => 0,
|
|
|
- '分摊空压机' => 0,
|
|
|
- '分摊鼓风机' => 0,
|
|
|
- '分摊其他' => 0,
|
|
|
- '待摊人工' => 0,
|
|
|
- '待摊折旧' => 0,
|
|
|
- '待摊场地租金' => 0,
|
|
|
- '待摊其他费用' => 0,
|
|
|
- '加工费' => 0,
|
|
|
- '加工费单价' => 0,
|
|
|
- '成本考核_胶印' => 0,
|
|
|
- '成本考核_凹印' => 0,
|
|
|
- '成本考核_丝印' => 0,
|
|
|
- '成本考核_模切' => 0,
|
|
|
- '成本考核_检验' => 0,
|
|
|
- '印版费' => 0,
|
|
|
- 'V23制造成本' => 0,
|
|
|
- 'Prt_rq' => date('Y-m-d H:i:s',time()),
|
|
|
- 'Sys_id' => '',
|
|
|
- 'Sys_rq' => date('Y-m-d H:i:s',time()),
|
|
|
- 'Mod_rq' => date('Y-m-d H:i:s',time()),
|
|
|
- 'U8UID' => '',
|
|
|
- 'Uniqid' => $lastId+1,
|
|
|
- '工序加工费' => 0,
|
|
|
- ];
|
|
|
- $sql= \db('工单_基本资料')->fetchSql(true)->insert($data);
|
|
|
- $res = \db()->query($sql);
|
|
|
- if ($res !== false){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增工单->客户代号列表获取
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\BindParamException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function ClientList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $sql = "SELECT DISTINCT
|
|
|
- (客户编号),rtrim(客户名称 ) as 客户名称
|
|
|
- FROM
|
|
|
- `产品_基本资料`
|
|
|
- GROUP BY
|
|
|
- 客户编号
|
|
|
- order by
|
|
|
- 客户编号";
|
|
|
- $list = \db()->query($sql);
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未找到客户列表');
|
|
|
- }
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $list[$key]['客户编号'] = rtrim($value['客户编号']);
|
|
|
- if ($value['客户编号'] == '1098'){
|
|
|
- $list[$key]['客户名称'] = '打样专用';
|
|
|
- }
|
|
|
- }
|
|
|
- $this->success('成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增工单->产品代号获取
|
|
|
- * @ApiMethod (GET)
|
|
|
- * @param void
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function ProductCodeList()
|
|
|
- {
|
|
|
- if ($this->request->isGet() === false){
|
|
|
- $this->error('请求错误');
|
|
|
- }
|
|
|
- $param = $this->request->param();
|
|
|
- if (empty($param)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $list = \db('产品_基本资料')
|
|
|
- ->where('客户编号',$param['cilent'])
|
|
|
- ->field('rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称')
|
|
|
- ->select();
|
|
|
- if (empty($list)){
|
|
|
- $this->success('未获取到产品数据');
|
|
|
- }
|
|
|
- $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);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|