|
|
@@ -19,6 +19,7 @@ use App\OwnerPriceOperation;
|
|
|
use App\OrderPackageCountingRecord;
|
|
|
use App\RejectedBill;
|
|
|
use App\Services\ForeignHaiRoboticsService;
|
|
|
+use App\Services\OwnerPriceOperationService;
|
|
|
use App\Services\StationService;
|
|
|
use App\Services\StorageService;
|
|
|
use App\Station;
|
|
|
@@ -69,186 +70,8 @@ class TestController extends Controller
|
|
|
|
|
|
public function test()
|
|
|
{
|
|
|
- app("CacheShelfService")->_stationCacheLightOff("HAIB1-01-01");
|
|
|
- app("CacheShelfService")->_stationCacheLightOff("HAIB1-01-02");
|
|
|
- app("CacheShelfService")->_stationCacheLightOff("HAIB1-02-02");
|
|
|
- dd(1);
|
|
|
- $stationTaskMaterialBox = StationTaskMaterialBox::query()->find(70370);
|
|
|
- DB::beginTransaction();
|
|
|
- try{
|
|
|
- $stationTaskMaterialBox->loadMissing("station");
|
|
|
- //如果为半箱位置 清理原有任务
|
|
|
- if (!$stationTaskMaterialBox->station)return;
|
|
|
- if (app("StationService")->isHalfBoxLocation($stationTaskMaterialBox->station)){
|
|
|
- app("StationService")->locationOccupy($stationTaskMaterialBox->station->code,$stationTaskMaterialBox->material_box_id);
|
|
|
- //清除海柔库位信息
|
|
|
- app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]);
|
|
|
- $stationId = $stationTaskMaterialBox->station_id;
|
|
|
- $tasks = TaskTransaction::query()->with("materialBox")->where(function ($query)use($stationId){
|
|
|
- $query->where("fm_station_id",$stationId)->orWhere("to_station_id",$stationId);
|
|
|
- })->where("status",0)->get();
|
|
|
- if ($tasks->count()!=0){
|
|
|
- $options = [];
|
|
|
- switch ($tasks[0]->mark){
|
|
|
- case 1:
|
|
|
- $options["title"] = '上架任务';
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- $options["title"] = '出库任务';
|
|
|
- break;
|
|
|
- default:
|
|
|
- $options["title"] = '未知类型';
|
|
|
- }
|
|
|
- switch ($tasks->count()){
|
|
|
- case 1:
|
|
|
- $task = $tasks[0];
|
|
|
- $options["detail01"] = $task->materialBox->code ?? '';
|
|
|
- $options["detail02"] = $task->doc_code ?: '跟踪:‘'.$task->track_num."’ 批次:‘".$task->lot_num."’";
|
|
|
- $options["detail03"] = $task->bar_code;
|
|
|
- $options["qty01"] = $task->amount;
|
|
|
- $options["uomDesc01"] = '件';
|
|
|
- $options["qty02"] = $task->bin_number;
|
|
|
- $options["uomDesc02"] = '号';
|
|
|
- break;
|
|
|
- default:
|
|
|
- $count = count(array_unique(array_column($tasks->toArray(),"commodity_id")));
|
|
|
- if ($count==1){
|
|
|
- $options["detail01"] = $tasks[0]->bar_code;
|
|
|
- $options["detail02"] = "";
|
|
|
- $options["detail03"] = "";
|
|
|
- $amount = 0;
|
|
|
- foreach ($tasks as $task){
|
|
|
- if (mb_strlen($options["detail02"])>20){
|
|
|
- $options["detail03"] .= $task->bin_number."号-".$task->amount."件,";
|
|
|
- }else $options["detail02"] .= $task->bin_number."号-".$task->amount."件,";
|
|
|
- $amount += $task->amount;
|
|
|
- }
|
|
|
- $options["detail02"] = rtrim($options["detail02"],",");
|
|
|
- $options["detail03"] = rtrim($options["detail03"],",");
|
|
|
- $options["qty02"] = $amount;
|
|
|
- $options["uomDesc02"] = '件';
|
|
|
- }else{
|
|
|
- $task = $tasks[0];
|
|
|
- $options["detail01"] = $task->materialBox->code ?? '';
|
|
|
- $options["detail02"] = "货品过多请自行核对";
|
|
|
- $options["detail03"] = "波次:".$task->doc_code ?
|
|
|
- (Order::query()->with("batch")->where("code",$task->doc_code)->first()->batch->code ?? '无') : '无';
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- app("CacheShelfService")->lightUp($stationTaskMaterialBox->station->code,'2','0',$options);
|
|
|
- Cache::forget("CACHE_SHELF_OCCUPANCY_{$stationTaskMaterialBox->station->id}");//关闭无限亮灯
|
|
|
- }
|
|
|
- }else app("StationService")->locationFreed($stationTaskMaterialBox->station->code); //释放库位占用
|
|
|
- DB::commit();
|
|
|
- dd("OK");
|
|
|
- }catch (\Exception $e){
|
|
|
- DB::rollBack();
|
|
|
- dd($e->getTrace());
|
|
|
- }
|
|
|
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- //快递称重 生成历史数据
|
|
|
- public function addRecord(Request $request)
|
|
|
- {
|
|
|
- ini_set('max_execution_time',-1);
|
|
|
- OrderPackageCountingRecord::query()->truncate();
|
|
|
- $start = Carbon::parse(request("month"))->startOfMonth();
|
|
|
- $end = Carbon::parse(request('month'))->endOfMonth();
|
|
|
-
|
|
|
- foreach (CarbonPeriod::create($start,$end) as $date){
|
|
|
- /** @var $date Carbon */
|
|
|
- $yesterday = $date->format("Y-m-d");
|
|
|
- $sql = <<<sql
|
|
|
-SELECT DATE_FORMAT(order_packages.created_at,'%Y-%m-%d') date,IFNULL(order_packages.measuring_machine_id,0) measuring_machine_id,order_packages.owner_id,
|
|
|
-SUM(CASE WHEN order_packages.weighed_at IS NOT NULL THEN 1 ELSE 0 END) AS count,
|
|
|
-COUNT(1) total FROM order_packages LEFT JOIN orders ON order_packages.order_id=orders.id
|
|
|
-WHERE orders.wms_status != '订单取消'
|
|
|
-AND order_packages.created_at BETWEEN '{$yesterday} 00:00:00' AND '{$yesterday} 23:59:59' GROUP BY date,order_packages.measuring_machine_id,order_packages.owner_id
|
|
|
-sql;
|
|
|
- $result = DB::select(DB::raw($sql));
|
|
|
- if (!$result) {
|
|
|
- $obj = [
|
|
|
- "targeted_at" => $yesterday,
|
|
|
- "un_weigh_count" => 0,
|
|
|
- "total_count" => 0,
|
|
|
- "measuring_machine_id" => 0,
|
|
|
- "owner_id" => 0
|
|
|
- ];
|
|
|
- $model = OrderPackageCountingRecord::query()->create($obj);
|
|
|
- Cache::put("weight.".$yesterday, $obj);
|
|
|
- }else{
|
|
|
- $objs = [];
|
|
|
- foreach ($result as $v){
|
|
|
- $obj = [
|
|
|
- "targeted_at" => $v->date,
|
|
|
- "un_weigh_count" => $v->count,
|
|
|
- "total_count" => $v->total,
|
|
|
- "measuring_machine_id" => $v->measuring_machine_id,
|
|
|
- "owner_id" => $v->owner_id
|
|
|
- ];
|
|
|
- $model = OrderPackageCountingRecord::query()->create($obj);
|
|
|
- array_push($objs, $obj);
|
|
|
- }
|
|
|
- Cache::put("weight.".$yesterday, $objs);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function redis()
|
|
|
- {
|
|
|
- $start = 1606752000;$end = 1627747200;
|
|
|
- $len = ($end - $start) / 86400;
|
|
|
- for ($i=0; $i <= $len ; $i ++){
|
|
|
- $date = date("Y-m-d", $start + $i * 86400);
|
|
|
- Cache::pull('weight.'.$date);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function delRedis(Request $request)
|
|
|
- {
|
|
|
- $date = $request->get('date','');
|
|
|
- if (empty($date)) return false;
|
|
|
- Cache::pull('weight.'.$date);
|
|
|
- }
|
|
|
|
|
|
- public function addDateRecords(Request $request)
|
|
|
- {
|
|
|
- $yesterday = $request->get('date','');
|
|
|
- $sql = <<<sql
|
|
|
-SELECT DATE_FORMAT(order_packages.created_at,'%Y-%m-%d') date,IFNULL(order_packages.measuring_machine_id,0) measuring_machine_id,order_packages.owner_id,
|
|
|
-SUM(CASE WHEN order_packages.weighed_at IS NOT NULL THEN 1 ELSE 0 END) AS count,
|
|
|
-COUNT(1) total FROM order_packages LEFT JOIN orders ON order_packages.order_id=orders.id
|
|
|
-WHERE orders.wms_status != '订单取消'
|
|
|
-AND order_packages.created_at BETWEEN '{$yesterday} 00:00:00' AND '{$yesterday} 23:59:59' GROUP BY date,order_packages.measuring_machine_id,order_packages.owner_id
|
|
|
-sql;
|
|
|
- $result = DB::select(DB::raw($sql));
|
|
|
- if (!$result) {
|
|
|
- $obj = [
|
|
|
- "targeted_at" => $yesterday,
|
|
|
- "un_weigh_count" => 0,
|
|
|
- "total_count" => 0,
|
|
|
- "measuring_machine_id" => 0,
|
|
|
- "owner_id" => 0
|
|
|
- ];
|
|
|
- $model = OrderPackageCountingRecord::query()->create($obj);
|
|
|
- Cache::put("weight.".$yesterday, $obj);
|
|
|
- }else{
|
|
|
- $objs = [];
|
|
|
- foreach ($result as $v){
|
|
|
- $obj = [
|
|
|
- "targeted_at" => $v->date,
|
|
|
- "un_weigh_count" => $v->count,
|
|
|
- "total_count" => $v->total,
|
|
|
- "measuring_machine_id" => $v->measuring_machine_id,
|
|
|
- "owner_id" => $v->owner_id
|
|
|
- ];
|
|
|
- $model = OrderPackageCountingRecord::query()->create($obj);
|
|
|
- array_push($objs, $obj);
|
|
|
- }
|
|
|
- Cache::put("weight.".$yesterday, $objs);
|
|
|
- }
|
|
|
}
|
|
|
}
|