146 lines
5.7 KiB
PHP
146 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace app\action;
|
|
|
|
use Exception;
|
|
use libs\db\Db;
|
|
|
|
class SetIqcResult
|
|
{
|
|
public function execute($post)
|
|
{
|
|
// 验证数据
|
|
$param = check_valid($post['action'], [
|
|
['inbound_id', 'int', 'iqc检测数据集'],
|
|
], $post['param']);
|
|
|
|
try {
|
|
// 获取数据
|
|
$iqcListData = Db::fetchAll("select * from hf_mes_wms_examine where inbound_id={$param['inbound_id']} ORDER BY id ASC;");
|
|
|
|
foreach ($iqcListData as $item){
|
|
Db::insert('hf_mes_wms_grounding', [
|
|
'create_user_id' => $item['create_user_id'],
|
|
'inbound_id' => $item['inbound_id'],
|
|
'inbound_details_id' => $item['inbound_details_id'],
|
|
'wms_examine_id' => $item['id'],
|
|
'is_examine' => 1,
|
|
'status' => 0,
|
|
'wms_material_id' => $item['wms_material_id'],
|
|
'create_time' => date('Y-m-d H:i:s')
|
|
|
|
]);
|
|
}
|
|
|
|
// // 检索是否存在必要字段
|
|
// foreach ($iqcListData as $idx => $item) {
|
|
// $idx = $idx + 1;
|
|
// $check_feilds = ['inbound_code', 'material_code', 'create_time', 'update_time', 'active'];
|
|
// foreach ($check_feilds as $val) {
|
|
// if ($val == 'active') {
|
|
// if (!isset($item[$val])) {
|
|
// throw new Exception("供应商数据集第[{$idx}]位置数据对象不存在字段[{$val}]");
|
|
// }
|
|
// if (!in_array($item[$val], [0, 1])) {
|
|
// throw new Exception("供应商数据集第[{$idx}]位置数据对象对应的字段[{$val}]值只能是0或者1");
|
|
// }
|
|
// } else {
|
|
// if (!isset($item[$val])) {
|
|
// throw new Exception("供应商数据集第[{$idx}]位置数据对象不存在字段[{$val}]");
|
|
// }
|
|
// if (empty($item[$val])) {
|
|
// throw new Exception("供应商数据集第[{$idx}]位置数据对象字段[{$val}]的值不能为空");
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// foreach ($supplierData as $value) {
|
|
// // 检测编码是否存在
|
|
// $sql = sprintf(
|
|
// "SELECT id
|
|
// FROM hf_mes_supplier
|
|
// WHERE code='%s' LIMIT 1;",
|
|
// $value['code']
|
|
// );
|
|
// $ret = Db::fetch($sql);
|
|
// if (!empty($ret)) {
|
|
// // 修改数据
|
|
// $update_keys = [
|
|
// 'name',
|
|
// 'code',
|
|
// 'create_time',
|
|
// 'update_time',
|
|
// 'active',
|
|
// 'address',
|
|
// 'contact_person',
|
|
// 'contact_number',
|
|
// 'email',
|
|
// 'remark',
|
|
// ];
|
|
// $update_str = '';
|
|
// foreach ($update_keys as $key){
|
|
// if(isset($value[$key])){
|
|
// if(!empty($value[$key])){
|
|
// if($key == 'active'){
|
|
// $update_str .= "\"{$key}\"={$value[$key]},";
|
|
// }else{
|
|
// $update_str .= "\"{$key}\"='{$value[$key]}',";
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// $sql = sprintf(
|
|
// "UPDATE \"%s\" SET %s WHERE id='%s'",
|
|
// 'hf_mes_supplier',
|
|
// rtrim($update_str, ','),
|
|
// $ret['id']
|
|
// );
|
|
// Db::query($sql);
|
|
// } else {
|
|
// // 新增数据
|
|
// $insert_keys = [
|
|
// 'name',
|
|
// 'code',
|
|
// 'create_time',
|
|
// 'update_time',
|
|
// 'active',
|
|
// 'address',
|
|
// 'contact_person',
|
|
// 'contact_number',
|
|
// 'email',
|
|
// 'remark',
|
|
// ];
|
|
// $insert_key_str = '';
|
|
// $insert_val_str = '';
|
|
// foreach ($insert_keys as $key){
|
|
// if(isset($value[$key])){
|
|
// if(!empty($value[$key])){
|
|
// $insert_key_str .= "\"{$key}\",";
|
|
//
|
|
// if($key == 'active'){
|
|
// $insert_val_str .= "{$value[$key]},";
|
|
// }else{
|
|
// $insert_val_str .= "'{$value[$key]}',";
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// $sql = sprintf(
|
|
// "INSERT INTO %s(%s) VALUES (%s)",
|
|
// 'hf_mes_supplier',
|
|
// rtrim($insert_key_str, ','),
|
|
// rtrim($insert_val_str, ',')
|
|
// );
|
|
// Db::query($sql);
|
|
// }
|
|
// }
|
|
} catch (Exception $e) {
|
|
throw new Exception($e->getMessage());
|
|
}
|
|
|
|
return '';
|
|
}
|
|
}
|