| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use Monolog\Handler\IFTTTHandler;
- use think\Db;
- /**
- * 工单资料管理
- */
- 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('请求错误');
- }
- $where = [
- '行号' => '1',
- ];
- $ClientList = Db::table('erp_客户供应商')->where('类型','客户')->cache(true)->column('简称','编号');
- //获取总计划中数量和总生产中数量
- $productingAll = Db::table('工单_基本资料')->where('gd_statu','2-生产中')->cache(true)->count();
- $progressAll = Db::table('工单_基本资料')->where('gd_statu','3-计划中')->cache(true)->count();
- $data = [
- 'productingAll' => $productingAll,
- 'progressAll' => $progressAll
- ];
- //按客户编号查询生产中,计划中数量
- foreach ($ClientList as $key=>$value){
- $order = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->cache(true)->count();
- if ($order !== 0){
- $productIng = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where($where)->where('gd_statu','2-生产中')->cache(true)->count();
- $proGress = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->where($where)->where('gd_statu','3-计划中')->cache(true)->count();
- $code = Db::table('工单_基本资料')->where('Gd_客户代号',$key)->field('rtrim(成品代号) as 成品代号')->cache(true)->find();
- $Detail = [
- 'Gd_khdh' => substr($code['成品代号'],0,4),
- 'Gd_khmc' => rtrim($value),
- 'producting' => $productIng = 0?'':"生产中:".$productIng,
- 'progress' => $proGress=0?'':'计划中:'.$proGress,
- ];
- $menu = $Detail['Gd_khdh'].'【'.$Detail['producting'].$Detail['progress'].'】'.'【'.$Detail['Gd_khmc'].'】';
- array_push($data,$menu);
- }
- }
- $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');
- $limit = input('limit');
- // $page = input('page');
- $clientNumber = input('Gd_khdh');
- $startTime = input('start');
- $endTime = input('end');
- $where = [
- '成品代号' => ['like',$clientNumber.'%']
- ];
- // if (isset($search)){
- // $where['']
- // }
- if (isset($startTime) && isset($endTime)){
- $where['接单日期'] = ['between',[$startTime,$endTime]];
- }
- // $config = [
- // 'page_param' => $page,
- // 'per_page' => $limit
- // ];
- $list = Db::table('工单_基本资料')
- ->where($where)
- ->order('接单日期 desc')
- ->paginate($limit);
- //工单基本资料数据整理
- $data = [];
- foreach ($list->items() 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']),
- ];
- }
- $this->success('成功',$data);
- }
- /**
- * 印件资料
- * @ApiMethod (GET)
- * @param string $Gd_gdbh 工单编号
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function Printed()
- {
- if ($this->request->isGet() === false){
- $this->error('请求错误');
- }
- $Gd_gdbh = input('Gd_gdbh');
- if (empty($Gd_gdbh)){
- $this->error('参数错误');
- }
- $list = Db::table('工单_印件资料')->where('Yj_Gdbh',$Gd_gdbh)->select();
- $data = [];
- if ($list){
- foreach ($list as $key=>$value){
- $data[$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']),
- ];
- }
- }
- $this->success('成功',$data);
- }
- /**
- * 工艺资料
- * @ApiMethod (GET)
- * @param string $Gd_gdbh 工单编号
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function Craft()
- {
- if ($this->request->isGet() === false){
- $this->error('请求错误');
- }
- $Gd_gdbh = input('Gd_gdbh');
- if (empty($Gd_gdbh)){
- $this->error('参数错误');
- }
- $list = Db::table('工单_工艺资料')
- ->where('Gy0_gdbh',$Gd_gdbh)
- ->select();
- $Gd_cpdh = Db::table('工单_基本资料')->where('Gd_gdbh',$Gd_gdbh)->field('Gd_cpdh')->find();
- $data = [];
- if ($list){
- foreach ($list 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'];
- }
- $where = [
- 'Gy0_cpdh' => $Gd_cpdh['Gd_cpdh'],
- 'Gy0_yjno' => $value['Gy0_yjno'],
- 'Gy0_gxh' => $value['Gy0_gxh'],
- ];
- $product = Db::table('产品_工艺资料')->where($where)->field('工价系数,损耗系数')->find();
- $data[$key] = [
- '重点工序' => rtrim($value['重点工序']),
- '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
- '备选工序' => '',
- '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
- '计划产量' => rtrim($value['Gy0_计划接货数']),
- '基础损耗' => rtrim($value['Gy0_Rate0']),
- '损耗率' => rtrim($value['Gy0_Rate1']),
- '报废定额' => '',
- '允损比例' => '',
- '难度系数' => isset($product['工价系数'])?rtrim($product['工价系数']):'',
- '损耗系数' => isset($product['损耗系数'])?rtrim($product['损耗系数']):'',
- '人工检_次品板' => (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']):'',
- ];
- }
- }
- $this->success('成功',$data);
- }
- /**
- * BOM资料
- * @ApiMethod (GET)
- * @param string $Gd_gdbh 工单编号
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function Bom()
- {
- if ($this->request->isGet() === false){
- $this->error('请求错误');
- }
- $Gd_gdbh = input('Gd_gdbh');
- if (empty($Gd_gdbh)){
- $this->error('参数错误');
- }
- $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 更新时间';
- $list = Db::table('工单_bom资料')
- ->where('BOM_工单编号',$Gd_gdbh)
- ->field($field)
- ->select();
- foreach ($list as $key=>$value){
- $list[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
- unset($list[$key]['BOM_投料单位'],$list[$key]['BOM_投入数'],$list[$key]['BOM_产出数'],$list[$key]['BOM_产出单位']);
- $list[$key]['计划用量'] = rtrim((float)$value['计划用量']);
- }
- $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 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 备注';
- $list = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
- if (empty($list)){
- $this->error('未找到该工单信息');
- }
- $printData = Db::table('工单_印件资料')
- ->where('Yj_Gdbh',$workOrder)
- ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料')
- ->find();
- if (empty($printData)){
- $this->error('未找到该工单印件资料');
- }
- $list['印件名称'] = $printData['印件名称'];
- $list['印件代号'] = $printData['印件代号'];
- $list['平张投料'] = $printData['平张投料'];
- $this->success('成功',$list);
- }
- /**
- * 工单资料修改
- * @ApiMethod (POST)
- * @param array $data 上传数据
- * @return void
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function WorkOrderEdit()
- {
- if ($this->request->isPost() === false){
- $this->error('请求错误');
- }
- $data = input('data');
- if (empty($data)){
- $this->error('参数错误');
- }
- $sql = Db::table('工单_基本资料')->where('Gd_gdbh',$data['Gd_gdbh'])->fetchSql(true)->update($data);
- $res = Db::query($sql);
- if ($res === 0){
- $this->error('修改失败');
- }
- $this->success('成功');
- }
- /**
- * 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::table('产品_工艺资料')->where('Gy0_cpdh',$productCode)->field($field)->select();
- if (empty($list)){
- $this->error('未找到该产品工序');
- }
- foreach ($list as $key=>$value){
- $data = Db::table('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::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
- if (empty($Detail)){
- $this->error('未找到工单信息');
- }
- $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 ($this->request->isPost() === false)
- {
- $this->error('请求错误');
- }
- $oldWorkOrder = input('oldWorkOrder');
- $newWorkOrder = input('newWorkOrder');
- if (empty($oldWorkOrder) || empty($newWorkOrder))
- {
- $this->error('参数错误');
- }
- //获取原工单工艺资料
- $oldProcessData = Db::table('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
- $ProsessUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
- foreach ($oldProcessData as $k=>$v){
- $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
- $oldProcessData[$k]['Sys_id'] = '';
- $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
- }
- if (Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
- Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
- }
- //获取原工单印件资料
- $oldPrintData = Db::table('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->select();
- $PrintUniqId = Db::table('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
- foreach ($oldPrintData as $k=>$v){
- $oldPrintData[$k]['Yj_Gdbh'] = $newWorkOrder;
- $oldPrintData[$k]['Sys_id'] = '';
- $oldPrintData[$k]['Uniqid'] = $PrintUniqId['Uniqid'] +$k +1;
- }
- if (Db::table('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->find()){
- Db::table('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->delete();
- }
- //复制印件、工艺资料
- $ProcessSQL = Db::table('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
- $ProcessRes = Db::query($ProcessSQL);
- $PrintSQL = Db::table('工单_印件资料')->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::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
- if (empty($list)){
- $this->error('未找到工单信息');
- }
- $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 更新时间';
- $process = Db::table('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->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::table('工单_基本资料')->where('成品代号',$productCode)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
- if (empty($list)){
- $this->error('未获取该产品其他工单信息');
- }
- $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 ($this->request->isPost() === false){
- $this->error('请求错误');
- }
- $oldWorkOrder = input('oldWorkOrder');
- $newWorkOrder = input('newWorkOrder');
- if (empty($oldWorkOrder) || empty($newWorkOrder))
- {
- $this->error('参数错误');
- }
- //获取原工单工艺资料
- $oldProcessData = Db::table('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->select();
- $ProsessUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
- foreach ($oldProcessData as $k=>$v){
- $oldProcessData[$k]['Gy0_gdbh'] = $newWorkOrder;
- $oldProcessData[$k]['Sys_id'] = '';
- $oldProcessData[$k]['Mod_rq'] = date('Y-m-d H:i:s',time());
- $oldProcessData[$k]['UniqId'] = $ProsessUniqId['UniqId'] + $k + 1;
- }
- if (Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->find()){
- Db::table('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->delete();
- }
- //插入工艺资料
- $ProcessSQL = Db::table('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
- $ProcessRes = Db::query($ProcessSQL);
- if ($ProcessRes !== false){
- $this->success('成功');
- }else{
- $this->error('失败');
- }
- }
- /**
- * 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('workOrder');
- if (empty($workOrder)){
- $this->error('参数错误');
- }
- $res = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->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 设备编号';
- $list = Db::table('工单_工艺资料')->where($where)->field($filed)->select();
- if (empty($list)){
- $this->error('未找到该工单工艺');
- }
- $name = Db::table('工单_基本资料')
- ->where('Gd_gdbh',$workOrder)
- ->field('rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_khmc) as 客户名称,rtrim(Gd_cpmc) as 产品名称')
- ->find();
- if (empty($name)){
- $this->error('未找到该工单');
- }
- 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 ($this->request->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::table('工单_工艺资料')->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 损耗系数';
- $list = Db::table('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($field)->select();
- if (empty($list)){
- $this->error('未找到该工单工艺资料');
- }
- 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 (GET)
- * @param string workorder 工单编号
- * @param string processCode 工序号
- * @param float difficulty 难度系数
- * @param string loss 损耗代号
- * @param string peintMode 印刷方式
- * @param float plate 版距
- * @param float chromatic 计损色数
- * @param float wastage 损耗系数
- * @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 ($this->request->isPost() === false){
- $this->error('请求错误');
- }
- $workOrder = input('workOrder');
- $processCode = input('processCode');
- if (empty($workOrder) || empty($processCode)){
- $this->error('参数错误');
- }
- $row = [
- '工价系数' => input('difficulty'),
- 'Gy0_shdh' => input('loss'),
- '印刷方式' => input('printMode'),
- '版距' => input('plate'),
- 'Gy0_ms' => input('chromatic'),
- '损耗系数' => input('wastage'),
- ];
- //根据损耗代号获取基础损耗、损耗率
- $data = Db::table('dic_lzsh')->where('sys_bh',$row['Gy0_shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
- $row['基础损耗'] = $data['rate0'];
- $row['损耗率'] = $data['rate1'];
- $sql = Db::table('工单_工艺资料')->where(['Gy0_gdbh'=>$workOrder,'Gy0_gxh'=>$processCode])->fetchSql(true)->update($row);
- $res = Db::query($sql);
- if ($res !== false){
- $this->success('成功');
- }else{
- $this->error('失败');
- }
- }
- //工单工序产量统计
- public function OutputStatistics()
- {
- if ($this->request->isGet() === false){
- $this->error('请求错误');
- }
- $workOrder = input('workOrder');
- if (empty($workOrder)){
- $this->error('参数错误');
- }
- // $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,rtrim(Gy0_计划接货数) as 工序计划产量,
- // rtrim(Gy0_ls) as 联数,'
- }
- }
|