|
|
@@ -2346,5 +2346,90 @@ class WorkOrderSpotCheck extends Api{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 出库报工
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function outReport()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = Request::instance()->post();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ foreach ($param as $key=>$value){
|
|
|
+ if ($value['number'] != '' || $value['number'] == 0 ){
|
|
|
+ $lastNumber = \db('工单_bom资料')
|
|
|
+ ->where('BOM_工单编号',$value['order_id'])
|
|
|
+ ->where('BOM_物料名称',$value['物料名称'])
|
|
|
+ ->field('BOM_库存总量,BOM_面料结余,Bom_领用数量,BOM_退还数量')
|
|
|
+ ->find();
|
|
|
+ if ($value['name'] === '出库'){
|
|
|
+ $lastNumber['BOM_面料结余'] -= $value['number'];
|
|
|
+ $lastNumber['Bom_领用数量'] += $value['number'];
|
|
|
+ }elseif ($value['name'] === '退还'){
|
|
|
+ $lastNumber['BOM_面料结余'] += $value['number'];
|
|
|
+ $lastNumber['BOM_退还数量'] += $value['number'];
|
|
|
+ }else{
|
|
|
+ $lastNumber['BOM_库存总量'] += $value['number'];
|
|
|
+ $lastNumber['BOM_面料结余'] += $value['number'];
|
|
|
+ }
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ //更新工单BOM表数据
|
|
|
+ $BomSql = \db('工单_bom资料')
|
|
|
+ ->where('BOM_工单编号',$value['order_id'])
|
|
|
+ ->where('BOM_物料名称',$value['物料名称'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update($lastNumber);
|
|
|
+ $res = \db()->query($BomSql);
|
|
|
+ //添加出库、退还历史记录
|
|
|
+ $reportSql = \db('设备_报工日志')
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->insert($value);
|
|
|
+ $reportRes = \db()->query($reportSql);
|
|
|
+
|
|
|
+ //提交事务
|
|
|
+ Db::commit();
|
|
|
+ }catch (\Exception $e){
|
|
|
+ //回滚事务
|
|
|
+ Db::rollback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 订单信息模糊查询
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function orderSearch()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $list = \db('工单_基本资料')
|
|
|
+ ->where('订单编号|生产款号','like','%'.$param['search'].'%')
|
|
|
+ ->where('Mod_rq',null)
|
|
|
+ ->field('订单编号,生产款号,客户编号,款式,接单日期,Sys_id as 创建人员,Sys_rq as 创建时间')
|
|
|
+ ->select();
|
|
|
+ if (empty($list)){
|
|
|
+ $this->success('未找到相关订单信息');
|
|
|
+ }else{
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|