|
@@ -2575,38 +2575,39 @@ class WorkOrderSpotCheck extends Api{
|
|
|
if (empty($param)){
|
|
if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- //查询库存表中的数量
|
|
|
|
|
- $Inventory = \db('物料_库存')
|
|
|
|
|
- ->where('批次号',$param['批次号'])
|
|
|
|
|
- ->field('库存数量,领用数量')
|
|
|
|
|
- ->find();
|
|
|
|
|
- //构建物料库存数据
|
|
|
|
|
- $InventoryData = [
|
|
|
|
|
- '库存数量' => $Inventory['库存数量'] - (int)$param['number'],
|
|
|
|
|
- '领用数量' => $Inventory['领用数量'] + (int)$param['number']
|
|
|
|
|
- ];
|
|
|
|
|
- $ReportData = $param;
|
|
|
|
|
- unset($ReportData['关联编号']);
|
|
|
|
|
- $ReportData['批次号'] = $param['批次号'];
|
|
|
|
|
- $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
- $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
- //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
- Db::startTrans();
|
|
|
|
|
- try {
|
|
|
|
|
- //存储库存表数据
|
|
|
|
|
- $InventorySql = \db('物料_库存')->where('批次号',$param['批次号'])->fetchSql(true)->update($InventoryData);
|
|
|
|
|
- \db()->query($InventorySql);
|
|
|
|
|
- //存储入库报工表数据
|
|
|
|
|
- $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
- \db()->query($ReportSql);
|
|
|
|
|
|
|
+ foreach ($param as $item){
|
|
|
|
|
+ //查询库存表中的数量
|
|
|
|
|
+ $Inventory = \db('物料_库存')
|
|
|
|
|
+ ->where('批次号',$item['批次号'])
|
|
|
|
|
+ ->field('库存数量,领用数量')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ //构建物料库存数据
|
|
|
|
|
+ $InventoryData = [
|
|
|
|
|
+ '库存数量' => $Inventory['库存数量'] - (int)$item['number'],
|
|
|
|
|
+ '领用数量' => $Inventory['领用数量'] + (int)$item['number']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $ReportData = $item;
|
|
|
|
|
+ unset($ReportData['关联编号']);
|
|
|
|
|
+ $ReportData['批次号'] = $item['批次号'];
|
|
|
|
|
+ $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
+ $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
+ //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ //存储库存表数据
|
|
|
|
|
+ $InventorySql = \db('物料_库存')->where('批次号',$item['批次号'])->fetchSql(true)->update($InventoryData);
|
|
|
|
|
+ \db()->query($InventorySql);
|
|
|
|
|
+ //存储入库报工表数据
|
|
|
|
|
+ $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
+ \db()->query($ReportSql);
|
|
|
|
|
|
|
|
- //提交事务
|
|
|
|
|
- Db::commit();
|
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
|
- Db::rollback();
|
|
|
|
|
|
|
+ //提交事务
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
$this->success('成功');
|
|
$this->success('成功');
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2660,93 +2661,94 @@ class WorkOrderSpotCheck extends Api{
|
|
|
if (empty($param)){
|
|
if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
- //查询批次号是否存在
|
|
|
|
|
- $BatchNumber = \db('物料_库存')
|
|
|
|
|
- ->where('物料编号',$param['物料编码'])
|
|
|
|
|
- ->where('关联号',$param['关联编号'])
|
|
|
|
|
- ->column('批次号');
|
|
|
|
|
- if (empty($BatchNumber)){
|
|
|
|
|
- $LastNumber = \db('物料_库存')
|
|
|
|
|
- ->order('批次号 desc')
|
|
|
|
|
- ->value('批次号');
|
|
|
|
|
- if (!empty($LastNumber)){
|
|
|
|
|
- $BatchNumber[0] = 'PCH'.((int)substr($LastNumber,3) + 1);
|
|
|
|
|
|
|
+ foreach ($param as $item){
|
|
|
|
|
+ //查询批次号是否存在
|
|
|
|
|
+ $BatchNumber = \db('物料_库存')
|
|
|
|
|
+ ->where('物料编号',$item['物料编码'])
|
|
|
|
|
+ ->where('关联号',$item['关联编号'])
|
|
|
|
|
+ ->column('批次号');
|
|
|
|
|
+ if (empty($BatchNumber)){
|
|
|
|
|
+ $LastNumber = \db('物料_库存')
|
|
|
|
|
+ ->order('批次号 desc')
|
|
|
|
|
+ ->value('批次号');
|
|
|
|
|
+ if (!empty($LastNumber)){
|
|
|
|
|
+ $BatchNumber[0] = 'PCH'.((int)substr($LastNumber,3) + 1);
|
|
|
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $BatchNumber[0] = 'PCH1';
|
|
|
|
|
+ }
|
|
|
|
|
+ //构建库存表数据
|
|
|
|
|
+ $InventoryData = [
|
|
|
|
|
+ '批次号' => $BatchNumber[0],
|
|
|
|
|
+ '关联号' => $item['关联编号'],
|
|
|
|
|
+ '物料编号' => $item['物料编码'],
|
|
|
|
|
+ '物料名称' => $item['物料名称'],
|
|
|
|
|
+ '入仓总量' => $item['number'],
|
|
|
|
|
+ '库存数量' => $item['number'],
|
|
|
|
|
+ '单位' => '米',
|
|
|
|
|
+ '实际门幅' => $item['实际门幅'],
|
|
|
|
|
+ '状态' => 1,
|
|
|
|
|
+ 'sys_id' => $item['sys_id'],
|
|
|
|
|
+ 'sys_rq' => date('Y-m-d H:i:s',time())
|
|
|
|
|
+ ];
|
|
|
|
|
+ $ReportData = $item;
|
|
|
|
|
+ unset($ReportData['关联编号']);
|
|
|
|
|
+ unset($ReportData['实际门幅']);
|
|
|
|
|
+ $ReportData['批次号'] = $BatchNumber[0];
|
|
|
|
|
+ $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
+ $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
+ //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
+ db()->startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ //存储库存表数据
|
|
|
|
|
+ $InventorySql = \db('物料_库存')->fetchSql(true)->insert($InventoryData);
|
|
|
|
|
+ \db()->query($InventorySql);
|
|
|
|
|
+ //存储入库报工表数据
|
|
|
|
|
+ $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
+ \db()->query($ReportSql);
|
|
|
|
|
+
|
|
|
|
|
+ //提交事务
|
|
|
|
|
+ \db()->commit();
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
|
+ \db()->rollback();
|
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
- $BatchNumber[0] = 'PCH1';
|
|
|
|
|
- }
|
|
|
|
|
- //构建库存表数据
|
|
|
|
|
- $InventoryData = [
|
|
|
|
|
- '批次号' => $BatchNumber[0],
|
|
|
|
|
- '关联号' => $param['关联编号'],
|
|
|
|
|
- '物料编号' => $param['物料编码'],
|
|
|
|
|
- '物料名称' => $param['物料名称'],
|
|
|
|
|
- '入仓总量' => $param['number'],
|
|
|
|
|
- '库存数量' => $param['number'],
|
|
|
|
|
- '单位' => '米',
|
|
|
|
|
- '实际门幅' => $param['实际门幅'],
|
|
|
|
|
- '状态' => 1,
|
|
|
|
|
- 'sys_id' => $param['sys_id'],
|
|
|
|
|
- 'sys_rq' => date('Y-m-d H:i:s',time())
|
|
|
|
|
- ];
|
|
|
|
|
- $ReportData = $param;
|
|
|
|
|
- unset($ReportData['关联编号']);
|
|
|
|
|
- unset($ReportData['实际门幅']);
|
|
|
|
|
- $ReportData['批次号'] = $BatchNumber[0];
|
|
|
|
|
- $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
- $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
- //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
- db()->startTrans();
|
|
|
|
|
- try {
|
|
|
|
|
- //存储库存表数据
|
|
|
|
|
- $InventorySql = \db('物料_库存')->fetchSql(true)->insert($InventoryData);
|
|
|
|
|
- \db()->query($InventorySql);
|
|
|
|
|
- //存储入库报工表数据
|
|
|
|
|
- $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
- \db()->query($ReportSql);
|
|
|
|
|
-
|
|
|
|
|
- //提交事务
|
|
|
|
|
- \db()->commit();
|
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
|
- \db()->rollback();
|
|
|
|
|
- $this->error($e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- $this->success('成功');
|
|
|
|
|
- }else{
|
|
|
|
|
- //查询库存表中的数量
|
|
|
|
|
- $Inventory = \db('物料_库存')
|
|
|
|
|
- ->where('批次号',$BatchNumber[0])
|
|
|
|
|
- ->field('入仓总量,库存数量')
|
|
|
|
|
- ->find();
|
|
|
|
|
- //构建物料库存数据
|
|
|
|
|
- $InventoryData = [
|
|
|
|
|
- '实际门幅' => $param['实际门幅'],
|
|
|
|
|
- '入仓总量' => $Inventory['入仓总量'] + $param['number'],
|
|
|
|
|
- '库存数量' => $Inventory['库存数量'] + $param['number']
|
|
|
|
|
- ];
|
|
|
|
|
- $ReportData = $param;
|
|
|
|
|
- unset($ReportData['关联编号']);
|
|
|
|
|
- unset($ReportData['实际门幅']);
|
|
|
|
|
- $ReportData['批次号'] = $BatchNumber[0];
|
|
|
|
|
- $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
- $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
- //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
- \db()->startTrans();
|
|
|
|
|
- try {
|
|
|
|
|
- //存储库存表数据
|
|
|
|
|
- $InventorySql = \db('物料_库存')->where('批次号',$BatchNumber[0])->fetchSql(true)->update($InventoryData);
|
|
|
|
|
- \db()->query($InventorySql);
|
|
|
|
|
- //存储入库报工表数据
|
|
|
|
|
- $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
- \db()->query($ReportSql);
|
|
|
|
|
-
|
|
|
|
|
- //提交事务
|
|
|
|
|
- \db()->commit();
|
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
|
- \db()->rollback();
|
|
|
|
|
|
|
+ //查询库存表中的数量
|
|
|
|
|
+ $Inventory = \db('物料_库存')
|
|
|
|
|
+ ->where('批次号',$BatchNumber[0])
|
|
|
|
|
+ ->field('入仓总量,库存数量')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ //构建物料库存数据
|
|
|
|
|
+ $InventoryData = [
|
|
|
|
|
+ '实际门幅' => $item['实际门幅'],
|
|
|
|
|
+ '入仓总量' => $Inventory['入仓总量'] + $item['number'],
|
|
|
|
|
+ '库存数量' => $Inventory['库存数量'] + $item['number']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $ReportData = $item;
|
|
|
|
|
+ unset($ReportData['关联编号']);
|
|
|
|
|
+ unset($ReportData['实际门幅']);
|
|
|
|
|
+ $ReportData['批次号'] = $BatchNumber[0];
|
|
|
|
|
+ $ReportData['rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
+ $ReportData['库存数量'] = $InventoryData['库存数量'];
|
|
|
|
|
+ //创建事务,存储库存表数据和入库报工表数据
|
|
|
|
|
+ \db()->startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ //存储库存表数据
|
|
|
|
|
+ $InventorySql = \db('物料_库存')->where('批次号',$BatchNumber[0])->fetchSql(true)->update($InventoryData);
|
|
|
|
|
+ \db()->query($InventorySql);
|
|
|
|
|
+ //存储入库报工表数据
|
|
|
|
|
+ $ReportSql = \db('设备_报工日志')->fetchSql(true)->insert($ReportData);
|
|
|
|
|
+ \db()->query($ReportSql);
|
|
|
|
|
+
|
|
|
|
|
+ //提交事务
|
|
|
|
|
+ \db()->commit();
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
|
+ \db()->rollback();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- $this->success('成功');
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ $this->success('成功');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|