|
|
@@ -44,6 +44,7 @@ use App\Services\common\DataHandlerService;
|
|
|
use App\Services\InventoryCompareService;
|
|
|
use App\Services\LogService;
|
|
|
use App\Services\OracleActAllocationDetailService;
|
|
|
+use App\Services\OracleBasCustomerService;
|
|
|
use App\Services\OracleDOCOrderHeaderService;
|
|
|
use App\Services\OrderIssuePerformanceService;
|
|
|
use App\Services\OrderIssueService;
|
|
|
@@ -52,10 +53,12 @@ use App\Services\OrderPackageService;
|
|
|
use App\Services\OrderService;
|
|
|
use App\Services\OrderTrackingOwnerService;
|
|
|
use App\Services\OrderTrackingService;
|
|
|
+use App\Services\WarehouseService;
|
|
|
use App\StoreCheckingReceive;
|
|
|
use App\StoreCheckingReceiveItem;
|
|
|
use App\Unit;
|
|
|
use App\User;
|
|
|
+use App\Warehouse;
|
|
|
use App\Waybill;
|
|
|
use Carbon\Carbon;
|
|
|
use Exception;
|
|
|
@@ -66,6 +69,7 @@ use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
+use Ramsey\Collection\Collection;
|
|
|
use Zttp\Zttp;
|
|
|
|
|
|
class TestController extends Controller
|
|
|
@@ -81,6 +85,7 @@ class TestController extends Controller
|
|
|
{
|
|
|
return call_user_func([$this, $method], $request);
|
|
|
}
|
|
|
+
|
|
|
/*dd('IN_Warehouse:'.$doc_asn_detail->warehouseid,
|
|
|
'In_ASNNo_C:'.$doc_asn_detail->docno,
|
|
|
'In_ASNLineNo_C:'.$doc_asn_detail->asnlineno,
|
|
|
@@ -105,22 +110,24 @@ class TestController extends Controller
|
|
|
'In_UserID:'.$doc_asn_detail->addwho,
|
|
|
'OUT_Return_Code:'.$result
|
|
|
);*/
|
|
|
- public function test4(){
|
|
|
- $r=Redis::connection();
|
|
|
+ public function test4()
|
|
|
+ {
|
|
|
+ $r = Redis::connection();
|
|
|
$controller = new \App\Http\Controllers\Api\thirdPart\flux\StoreController();
|
|
|
return $controller->quickStorage('JSCS202010210001');
|
|
|
}
|
|
|
|
|
|
- public function test2(){
|
|
|
+ public function test2()
|
|
|
+ {
|
|
|
$db = DB::connection('oracle');
|
|
|
$db->beginTransaction();
|
|
|
- try{
|
|
|
+ try {
|
|
|
$bas = $db->select("SELECT * FROM BAS_CODES where codeid = 'IVC_STS' and code = '00'");
|
|
|
foreach ($bas as $a) {
|
|
|
$row = $db->update(DB::raw("UPDATE BAS_CODES set codename_c = '创建' WHERE codeid = ? and code = ?"), [$a->codeid, $a->code]);
|
|
|
if ($row > 0) $db->commit();
|
|
|
}
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
$db->rollBack();
|
|
|
}
|
|
|
}
|
|
|
@@ -478,56 +485,57 @@ class TestController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function test5(){
|
|
|
- ini_set('max_execution_time',2500);
|
|
|
- ini_set('memory_limit','1526M');
|
|
|
+ public function test5()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 2500);
|
|
|
+ ini_set('memory_limit', '1526M');
|
|
|
//清理冗余条码
|
|
|
// $this->cleanBarcode();
|
|
|
|
|
|
- while(true){
|
|
|
+ while (true) {
|
|
|
$toDay = Carbon::now();
|
|
|
$skus = DB::select(DB::raw('select sku from commodities group by sku,owner_id having count(*)>1 limit 500 '));
|
|
|
- $skus = array_column($skus,'sku');
|
|
|
+ $skus = array_column($skus, 'sku');
|
|
|
|
|
|
- $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku',$skus)->get();
|
|
|
+ $commodities = Commodity::query()->with('barcodes')->whereNotNull('owner_id')->whereIn('sku', $skus)->get();
|
|
|
|
|
|
|
|
|
- if (count($commodities) < 1)return "SUCCESS";
|
|
|
+ if (count($commodities) < 1) return "SUCCESS";
|
|
|
$commodityMap = [];
|
|
|
$commodityDel = [];
|
|
|
$commodityTag = [];
|
|
|
$commodityBar = [];
|
|
|
$createBarcodes = [];
|
|
|
$logs = [];
|
|
|
- foreach ($commodities as $commodity){
|
|
|
- if ($commodityMap[$commodity->sku.'_'.$commodity->owner_id] ?? false){
|
|
|
- $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
|
|
|
+ foreach ($commodities as $commodity) {
|
|
|
+ if ($commodityMap[$commodity->sku . '_' . $commodity->owner_id] ?? false) {
|
|
|
+ $codes = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
|
|
|
$logs[] = [
|
|
|
'id' => $commodity->id,
|
|
|
'sku' => $commodity->sku,
|
|
|
- 'owner_id'=>$commodity->owner_id,
|
|
|
- 'code'=>$codes,
|
|
|
+ 'owner_id' => $commodity->owner_id,
|
|
|
+ 'code' => $codes,
|
|
|
];
|
|
|
$commodityDel[] = $commodity->id;
|
|
|
- $commodityTag[$commodity->id] = $commodityMap[$commodity->sku.'_'.$commodity->owner_id];
|
|
|
+ $commodityTag[$commodity->id] = $commodityMap[$commodity->sku . '_' . $commodity->owner_id];
|
|
|
|
|
|
- $arr = array_diff($codes,$commodityBar[$commodity->sku.'_'.$commodity->owner_id]);
|
|
|
- foreach ($arr as $code){
|
|
|
- if (!$code)continue;
|
|
|
+ $arr = array_diff($codes, $commodityBar[$commodity->sku . '_' . $commodity->owner_id]);
|
|
|
+ foreach ($arr as $code) {
|
|
|
+ if (!$code) continue;
|
|
|
$createBarcodes[] = [
|
|
|
'code' => $code,
|
|
|
- 'commodity_id' => $commodityMap[$commodity->sku.'_'.$commodity->owner_id],
|
|
|
+ 'commodity_id' => $commodityMap[$commodity->sku . '_' . $commodity->owner_id],
|
|
|
'created_at' => $toDay,
|
|
|
];
|
|
|
}
|
|
|
- }else{
|
|
|
- $commodityMap[$commodity->sku.'_'.$commodity->owner_id] = $commodity->id;
|
|
|
- $commodityBar[$commodity->sku.'_'.$commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(),'code') : [];
|
|
|
+ } else {
|
|
|
+ $commodityMap[$commodity->sku . '_' . $commodity->owner_id] = $commodity->id;
|
|
|
+ $commodityBar[$commodity->sku . '_' . $commodity->owner_id] = $commodity->barcodes ? array_column($commodity->barcodes->toArray(), 'code') : [];
|
|
|
}
|
|
|
}
|
|
|
- dd($commodityMap,$commodityDel,$commodityTag);
|
|
|
- LogService::log(__METHOD__,'清理商品',json_encode($logs,JSON_UNESCAPED_UNICODE));
|
|
|
- LogService::log(__METHOD__,'重新分配商品',json_encode($commodityTag,JSON_UNESCAPED_UNICODE));
|
|
|
+ dd($commodityMap, $commodityDel, $commodityTag);
|
|
|
+ LogService::log(__METHOD__, '清理商品', json_encode($logs, JSON_UNESCAPED_UNICODE));
|
|
|
+ LogService::log(__METHOD__, '重新分配商品', json_encode($commodityTag, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
app('inventoryAccountMissionService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存盘点任务
|
|
|
app('inventoryCompareService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新库存对比
|
|
|
@@ -536,13 +544,14 @@ class TestController extends Controller
|
|
|
app('storeCheckingReceiveItemService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新入库盘收一体
|
|
|
app('orderPackageCommoditiesService')->batchUpdateItself('commodity_id', $commodityTag);//批量更新订单商品
|
|
|
|
|
|
- LogService::log(__METHOD__,'删除商品与对应条码',json_encode($commodityDel,JSON_UNESCAPED_UNICODE));
|
|
|
- CommodityBarcode::query()->whereIn('commodity_id',$commodityDel)->delete();
|
|
|
+ LogService::log(__METHOD__, '删除商品与对应条码', json_encode($commodityDel, JSON_UNESCAPED_UNICODE));
|
|
|
+ CommodityBarcode::query()->whereIn('commodity_id', $commodityDel)->delete();
|
|
|
Commodity::destroy($commodityDel);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function cleanBarcode(){
|
|
|
+ private function cleanBarcode()
|
|
|
+ {
|
|
|
|
|
|
$logCommodityBarcodes = CommodityBarcode::query()->where('code', "")->get();
|
|
|
if (count($logCommodityBarcodes) > 0) LogService::log(__METHOD__, "纠正商品-删除空条码", json_encode($logCommodityBarcodes, JSON_UNESCAPED_UNICODE));
|
|
|
@@ -627,7 +636,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
}
|
|
|
$updateCommodities[$del->commodity_id] = $target->commodity_id;
|
|
|
}
|
|
|
- if (count($updateCommodities) > 0){
|
|
|
+ if (count($updateCommodities) > 0) {
|
|
|
app('inventoryAccountMissionService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存盘点任务
|
|
|
app('inventoryCompareService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存对比
|
|
|
app('inventoryDailyLogService')->batchUpdateItself('commodity_id', $updateCommodities);//批量更新库存每日记录
|
|
|
@@ -714,7 +723,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
/** @var OrderService $orderService */
|
|
|
$orderService = app(OrderService::class);
|
|
|
$owners = app(OrderTrackingOwnerService::class)->getTrackingOrderOwner();
|
|
|
- $startDate = \Illuminate\Support\Carbon::parse('2020-10-10 00:00:00')->toDateTimeString();
|
|
|
+ $startDate = \Illuminate\Support\Carbon::parse('2020-10-28 00:00:00')->toDateTimeString();
|
|
|
$orderHeaders = OracleDOCOrderHeader::query()->with(['oracleDOCOrderDetails', 'actAllocationDetails', 'oracleBASCode'])
|
|
|
->where('addTime', '>=', $startDate)
|
|
|
->whereIn('customerID', data_get($owners, '*.code'))
|
|
|
@@ -722,8 +731,10 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
$orderService->updateByWmsOrders($orderHeaders);
|
|
|
$orderTrackingService->updateByWmsOrderHeaders($orderHeaders);
|
|
|
}
|
|
|
- public function test11(){
|
|
|
- $orderHeader = OracleDOCOrderHeader::query()->with('actAllocationDetails')->where('orderNo','SO201024001172')->get();
|
|
|
+
|
|
|
+ public function test11()
|
|
|
+ {
|
|
|
+ $orderHeader = OracleDOCOrderHeader::query()->with('actAllocationDetails')->where('orderNo', 'SO201024001172')->get();
|
|
|
dd(app(OrderService::class)->createByWmsOrder($orderHeader));
|
|
|
}
|
|
|
|
|
|
@@ -732,4 +743,43 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
|
|
|
dd(Request::all());
|
|
|
}
|
|
|
|
|
|
+ public function updateOrdersWarehouse()
|
|
|
+ {
|
|
|
+ /**
|
|
|
+ * @var DataHandlerService $dataHandlerService
|
|
|
+ * @var OrderService $orderService
|
|
|
+ */
|
|
|
+ $dataHandlerService = app(DataHandlerService::class);
|
|
|
+ $orderService = app(OrderService::class);
|
|
|
+ $page = 500;
|
|
|
+ $count = Order::query()->count();
|
|
|
+ $warehouse = Warehouse::query()->get();
|
|
|
+ $warehouse_map = $dataHandlerService->dataHeader(['code'], $warehouse);
|
|
|
+ for ($i = 0; $i < $count; $i += $page) {
|
|
|
+ $min = $i;$max = $i + $page;
|
|
|
+ $orders = Order::query()->where('id', '>=', $min)->where('id', '<=', $max)->get();
|
|
|
+ $orderNos = array_diff(array_unique(data_get($orders, '*.code')), ['', ' ', '*', null]);
|
|
|
+ if (count($orderNos)==0) continue;
|
|
|
+ /** @var Collection $orderHeaders */
|
|
|
+ $orderHeaders = OracleDOCOrderHeader::query()->whereIn('orderno', $orderNos)->get();
|
|
|
+ if ($orderHeaders->count() == 0) continue;
|
|
|
+ $orderHeader_map = $dataHandlerService->dataHeader(['orderno'], $orderHeaders);
|
|
|
+ $update_params = [];
|
|
|
+ $update_params[] = ['id', 'warehouse_id'];
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ $orderHeader = $dataHandlerService->getKeyValue(['orderno' => $order->code], $orderHeader_map);
|
|
|
+ if ($orderHeader == null) continue;
|
|
|
+ $warehouse = $dataHandlerService->getKeyValue(['code' => $orderHeader->warehouseid], $warehouse_map);
|
|
|
+ if ($warehouse == null) continue;
|
|
|
+ $update_params[] = [
|
|
|
+ 'id' => $order->id,
|
|
|
+ 'warehouse_id' => $warehouse->id
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $orderService->batchUpdate($update_params);
|
|
|
+ unset($orders, $orderHeaders, $update_params);
|
|
|
+ }
|
|
|
+ unset($warehouse);
|
|
|
+ }
|
|
|
+
|
|
|
}
|