|
|
@@ -6,6 +6,7 @@ use App\Authority;
|
|
|
use App\Batch;
|
|
|
use App\City;
|
|
|
use App\Commodity;
|
|
|
+use App\CommodityMaterialBoxModel;
|
|
|
use App\Components\AsyncResponse;
|
|
|
use App\Console\Commands\CreateOwnerAreaReport;
|
|
|
use App\Console\Commands\CreateOwnerBillReport;
|
|
|
@@ -25,6 +26,7 @@ use App\Jobs\LogisticAliJiSuSync;
|
|
|
use App\Jobs\LogisticYTOSync;
|
|
|
use App\Jobs\OrderCreateInstantBill;
|
|
|
use App\Jobs\OrderFreeze;
|
|
|
+use App\Jobs\ProcurementCheckConfirmInform;
|
|
|
use App\Jobs\StoreCreateInstantBill;
|
|
|
use App\Jobs\ResetInstantBill;
|
|
|
use App\LaborReport;
|
|
|
@@ -54,6 +56,7 @@ use App\ProcurementDeliverie;
|
|
|
use App\ProcurementQuotation;
|
|
|
use App\ProcurementTotalBill;
|
|
|
use App\RejectedBillItem;
|
|
|
+use App\Services\AuthorityService;
|
|
|
use App\Services\BatchService;
|
|
|
use App\Services\CacheService;
|
|
|
use App\Services\CacheShelfService;
|
|
|
@@ -61,6 +64,7 @@ use App\Services\CommodityService;
|
|
|
use App\Services\common\BatchUpdateService;
|
|
|
use App\Services\common\DataHandlerService;
|
|
|
use App\Services\common\QueryService;
|
|
|
+use App\Services\ConfigurationService;
|
|
|
use App\Services\DeliveryAppointmentService;
|
|
|
use App\Services\DocWaveHeaderService;
|
|
|
use App\Services\FeatureService;
|
|
|
@@ -68,10 +72,6 @@ use App\Services\InventoryCompareService;
|
|
|
use App\Services\LogisticService;
|
|
|
use App\Services\LogisticZopService;
|
|
|
use App\Services\LogService;
|
|
|
-use App\Services\NewOrderCountingRecordService;
|
|
|
-use App\Services\MaterialBoxService;
|
|
|
-use App\Services\MenuService;
|
|
|
-use App\Services\OracleDocAsnHerderService;
|
|
|
use App\Services\OracleDOCOrderHeaderService;
|
|
|
use App\Services\OracleDocWaveDetailService;
|
|
|
use App\Services\OrderCommodityService;
|
|
|
@@ -92,6 +92,7 @@ use App\Services\StoreService;
|
|
|
use App\Services\SupplierService;
|
|
|
use App\Station;
|
|
|
use App\StationTask;
|
|
|
+use App\StationTaskCommodity;
|
|
|
use App\StationTaskMaterialBox;
|
|
|
use App\Store;
|
|
|
use App\StationTaskBatch;
|
|
|
@@ -128,6 +129,7 @@ use Overtrue\LaravelPinyin\Facades\Pinyin;
|
|
|
use PhpMyAdmin\Server\Status\Data;
|
|
|
use PhpParser\Node\Stmt\DeclareDeclare;
|
|
|
use Ramsey\Collection\Collection;
|
|
|
+use Symfony\Component\ErrorHandler\Error\FatalError;
|
|
|
use Zttp\Zttp;
|
|
|
|
|
|
class TestController extends Controller
|
|
|
@@ -145,114 +147,21 @@ class TestController extends Controller
|
|
|
{
|
|
|
return call_user_func([$this, $method], $request);
|
|
|
}
|
|
|
+ public function test1(){
|
|
|
+ $aa = [1,2,3];
|
|
|
|
|
|
- public function test1()
|
|
|
- {
|
|
|
- $box = app("MaterialBoxService")->getAnEmptyBox([],$modelId);
|
|
|
- return view("test");
|
|
|
- }
|
|
|
-
|
|
|
- public function test2()
|
|
|
- {
|
|
|
- ini_set('max_execution_time',-1);
|
|
|
- $myfile = @fopen(base_path()."/database/data/menus.data", "a+");
|
|
|
- foreach (Menu::query()->get() as $menu){
|
|
|
- $txt = "INSERT INTO menus";
|
|
|
- $columns = "(";
|
|
|
- $values = "(";
|
|
|
- foreach ($menu->toArray() as $col=>$val){
|
|
|
- $columns .= "{$col},";
|
|
|
- if (!$val) $values .= "null,";
|
|
|
- else $values .= "'{$val}',";
|
|
|
- }
|
|
|
- $columns = mb_substr($columns,0,-1);
|
|
|
- $values = mb_substr($values,0,-1);
|
|
|
- $txt .= "{$columns}) VALUES{$values});\r\n";
|
|
|
- fwrite($myfile, $txt);
|
|
|
- }
|
|
|
- fclose($myfile);
|
|
|
-
|
|
|
- $myfile = @fopen(base_path()."/database/data/authorities.data", "a+");
|
|
|
- foreach (Authority::query()->get() as $authority){
|
|
|
- $txt = "INSERT INTO authorities";
|
|
|
- $columns = "(";
|
|
|
- $values = "(";
|
|
|
- foreach ($authority->toArray() as $col=>$val){
|
|
|
- $columns .= "{$col},";
|
|
|
- if (!$val) $values .= "null,";
|
|
|
- else $values .= "'{$val}',";
|
|
|
- }
|
|
|
- $columns = mb_substr($columns,0,-1);
|
|
|
- $values = mb_substr($values,0,-1);
|
|
|
- $txt .= "{$columns}) VALUES{$values});\r\n";
|
|
|
- fwrite($myfile, $txt);
|
|
|
- }
|
|
|
- fclose($myfile);
|
|
|
- dd("OK");
|
|
|
+ $this->test1(...$aa);
|
|
|
}
|
|
|
public function test()
|
|
|
{
|
|
|
- DB::beginTransaction();
|
|
|
- try{
|
|
|
- $mapping = [
|
|
|
- "43"=>[647],"40"=>[648,649,650],
|
|
|
- "612"=>[651],"210"=>[652],"274" => [653],"314"=>[654],"327"=>[655],
|
|
|
- "329"=>[656],"344"=>[657],"159"=>[646,658],"164"=>[660],
|
|
|
- "206"=>[661,662],"205"=>[663,664,665],"272"=>[666,667],
|
|
|
- "320"=>[668],"220"=>[669],"223"=>[670],"616"=>[671],"310"=>[672],
|
|
|
- "348"=>[673],"538"=>[674,675],"311"=>[676],"16"=>[677],"133"=>[678,679],
|
|
|
- "488"=>[688],"557"=>[689,690]
|
|
|
- ];
|
|
|
- foreach ($mapping as $key=>$arr){
|
|
|
- $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$key]);
|
|
|
- if (!$roles)continue;
|
|
|
- foreach ($roles as $role){
|
|
|
- foreach ($arr as $aId){
|
|
|
- DB::insert(DB::raw("INSERT INTO authority_role(id_authority,id_role) values (?,?)"),[$aId,$role->id_role]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $re = [
|
|
|
- 257=>1,
|
|
|
- 258=>2,
|
|
|
- 259=>3,
|
|
|
- 260=>4,
|
|
|
- 261=>5,
|
|
|
- 262=>6,
|
|
|
- 263=>7,
|
|
|
- 264=>8,
|
|
|
- 265=>9,
|
|
|
- 266=>10,
|
|
|
- 312=>11,
|
|
|
- 313=>12,
|
|
|
- 510=>13,
|
|
|
- ];
|
|
|
- foreach ($re as $key=>$val){
|
|
|
- $usId = $val;
|
|
|
- $auId = $key;
|
|
|
- $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
|
|
|
- if (!$roles)continue;
|
|
|
- foreach ($roles as $role){
|
|
|
- DB::insert(DB::raw("INSERT INTO role_user_work_group(role_id,user_work_group_id) values (?,?)"),[$role->id_role,$usId]);
|
|
|
- }
|
|
|
- }
|
|
|
- $owners = Authority::query()->where("name","like","\_%")->get();
|
|
|
- foreach ($owners as $owner){
|
|
|
- $owId = ltrim($owner->name,"_");
|
|
|
- $auId = $owner->id;
|
|
|
- $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
|
|
|
- if (!$roles)continue;
|
|
|
- foreach ($roles as $role){
|
|
|
- DB::insert(DB::raw("INSERT INTO owner_role(owner_id,role_id) values (?,?)"),[$owId,$role->id_role]);
|
|
|
- }
|
|
|
- }
|
|
|
- DB::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- DB::rollBack();
|
|
|
- dd($e->getMessage());
|
|
|
- }
|
|
|
- app("MenuService")->setMenu();//重建菜单缓存
|
|
|
- app("AuthorityService")->removeAllAuth();//移除所有用户权限缓存,这将在用户下次访问时重新建立
|
|
|
+ app('StorageService')->clearTask(['HAIB2-02-02','HAIB2-01-01']);
|
|
|
+ dd();
|
|
|
+ ini_set('max_execution_time', 0);
|
|
|
+ $orders = Order::query()->whereBetween("wms_edittime",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
|
|
|
+ ->whereNotIn("id",OwnerFeeDetail::query()->select("outer_id")
|
|
|
+ ->whereBetween("worked_at",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
|
|
|
+ ->where("outer_table_name","orders"))->get();
|
|
|
+ foreach ($orders->chunk(50) as $or)dispatch(new OrderCreateInstantBill($or));
|
|
|
}
|
|
|
public function orderCreateBill()
|
|
|
{
|
|
|
@@ -261,6 +170,23 @@ class TestController extends Controller
|
|
|
$ser->createInstantBill($order);
|
|
|
dd("order create bill success");
|
|
|
}
|
|
|
+ function mp(){
|
|
|
+ $stationTaskCommodities=StationTaskCommodity::query()->where('id',19942)->get();
|
|
|
+ StationTaskCommodity::query()
|
|
|
+ ->whereIn('id',data_get($stationTaskCommodities,'*.id')??[])
|
|
|
+ ->update(['status'=>'完成']);
|
|
|
+ $stationTaskMaterialBoxes=StationTaskMaterialBox::query()
|
|
|
+ ->whereIn('id', data_get($stationTaskCommodities, '*.station_task_material_box_id') ?? [])
|
|
|
+ ->get('material_box_id');
|
|
|
+ $storages= \App\Storage::query()->whereIn('commodity_id',data_get($stationTaskCommodities,'*.commodity_id')??[])
|
|
|
+ ->whereIn('material_box_id',data_get($stationTaskMaterialBoxes,'*.material_box_id')??[])
|
|
|
+ ->get();
|
|
|
+ foreach($storages as $storage){
|
|
|
+ $amountReducing=$stationTaskCommodities->where('material_box_id',$storage['material_box_id'])->first()['amount']??0;
|
|
|
+ $storage['amount']-=$amountReducing;
|
|
|
+ $storage->update();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function supplementMarchOwnerReport()
|
|
|
{
|
|
|
@@ -305,29 +231,6 @@ class TestController extends Controller
|
|
|
app('BatchService')->assignTasks($batches);
|
|
|
}
|
|
|
|
|
|
- public function zzd()
|
|
|
- {
|
|
|
- ini_set('max_execution_time', 2500);
|
|
|
- ini_set('memory_limit', '1526M');
|
|
|
- $menus = [
|
|
|
- "A管理" => [
|
|
|
- "A二级" => [
|
|
|
- "A三级"
|
|
|
- ]
|
|
|
- ],
|
|
|
- "B管理" => []
|
|
|
- ];
|
|
|
- /*$authorities = [
|
|
|
- "A管理"=>[
|
|
|
- "A二级"=>[9
|
|
|
- "A三级"=>[
|
|
|
- "A四级"
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ];*/
|
|
|
- }
|
|
|
-
|
|
|
public function updateLaborRemark()
|
|
|
{
|
|
|
$laborReports = LaborReport::query()->with(['remarks' => function ($query) {
|
|
|
@@ -506,6 +409,11 @@ class TestController extends Controller
|
|
|
broadcast(new BroadcastToStation(BroadcastToStation::ALL_STATION, $jsonStationTasks));
|
|
|
}
|
|
|
|
|
|
+ public function ld4()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function featureIt()
|
|
|
{
|
|
|
LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5, 2500);
|
|
|
@@ -1062,225 +970,6 @@ class TestController extends Controller
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public function addProcurementData()
|
|
|
- {
|
|
|
- $this->syncUserDetail();
|
|
|
- $this->addProcurementDeliver();
|
|
|
- $this->addProcurement();
|
|
|
- $this->addProcurementQuotation();
|
|
|
- $this->addProcurementCheckSheet();
|
|
|
- }
|
|
|
-
|
|
|
- public function syncUserDetail()
|
|
|
- {
|
|
|
- $sql = DB::raw('SELECT * from user where supplierid is not null');
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $user_Details = UserDetail::query()->where('created_at', 'like', '2021-04-12%')->get();
|
|
|
- $dataHandlerService = app(DataHandlerService::class);
|
|
|
- $user_Details_map = $dataHandlerService->dataHeader(['mobile_phone'], $user_Details);
|
|
|
- foreach ($params as $param) {
|
|
|
- $user_detail = $dataHandlerService->getKeyValue(['mobile_phone' => $param->mobile], $user_Details_map);
|
|
|
- if (!$user_detail) continue;
|
|
|
- $user_detail->update(['procurement_wechat_open_id' => $param->openid]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function addProcurementDeliver()
|
|
|
- {
|
|
|
- //送货单
|
|
|
- $sql = DB::raw('SELECT
|
|
|
-deliver.id id,request.id procurement_id,deliver.delivernum amount,deliver.status status,deliver.accepttime signed_at,
|
|
|
-deliver.createtime created_at,deliver.createtime updated_at,deliver.confirmnum receipt_amount
|
|
|
-from deliver
|
|
|
-LEFT JOIN purch on deliver.purchid=purch.id
|
|
|
-LEFT JOIN ask on purch.askid=ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where purch.islower=1');
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $insert = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- $insert[] = [
|
|
|
- 'id' => $param->id,
|
|
|
- 'procurement_id' => $param->procurement_id,
|
|
|
- 'amount' => $param->amount,
|
|
|
- 'status' => $param->status ? $param->status - 1 : $param->status,
|
|
|
- 'signed_at' => Carbon::parse($param->signed_at)->toDateString(),
|
|
|
- 'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
|
|
|
- 'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
|
|
|
- 'receipt_amount' => $param->receipt_amount,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementDeliverie::query()->insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- public function addProcurement()
|
|
|
- {
|
|
|
-
|
|
|
- //采购单
|
|
|
- $sql = DB::raw('select request.id id,
|
|
|
-request.number code,request.type type,request.resourceid owner_material_id,purch.supplierid supplier_id,request.num quantity, request.sellnum amount,
|
|
|
-request.price unit_price,purch.acceptprice cost_price,request.status status,request.createtime created_at,request.createtime updated_at,
|
|
|
-purch.accepttime deadline
|
|
|
-from purch
|
|
|
-LEFT JOIN ask on purch.askid= ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where purch.islower=1 and request.type=3 ORDER BY request.id ASC');
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $insert = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- if (!$param->status) continue;
|
|
|
- if ($param->status == 0) $status = 10;
|
|
|
- if ($param->status == 1) $status = 0;
|
|
|
- if ($param->status == 2) $status = 1;
|
|
|
- if ($param->status == 3) $status = 2;
|
|
|
- if ($param->status == 4) $status = 11;
|
|
|
- if ($param->status == 5) $status = 4;
|
|
|
- if ($param->status == 6) $status = 5;
|
|
|
- if ($param->status == 7) $status = 6;
|
|
|
- if ($param->status == 8) $status = 8;
|
|
|
- if ($param->status == 9) $status = 9;
|
|
|
- $key = $param->id;
|
|
|
- $insert[$key] = [
|
|
|
- 'id' => $param->id,
|
|
|
- 'code' => $param->code,
|
|
|
- 'type' => 0,
|
|
|
- 'owner_material_id' => $param->owner_material_id,
|
|
|
- 'supplier_id' => $param->supplier_id,
|
|
|
- 'quantity' => $param->quantity,
|
|
|
- 'amount' => $param->amount,
|
|
|
- 'unit_price' => $param->unit_price,
|
|
|
- 'cost_price' => $param->cost_price,
|
|
|
- 'initiator' => 0,
|
|
|
- 'status' => $status,
|
|
|
- 'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
|
|
|
- 'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
|
|
|
- 'deadline' => Carbon::parse($param->deadline)->toDateTimeString(),
|
|
|
- ];
|
|
|
- }
|
|
|
- Procurement::query()->insert($insert);
|
|
|
-
|
|
|
- //打样 或者 询价
|
|
|
- $procurement_ids = Procurement::query()->select('id')->get();
|
|
|
- $ids = $procurement_ids->map(function ($procurement) {
|
|
|
- return $procurement['id'];
|
|
|
- });
|
|
|
- $idSql = "(''";
|
|
|
- foreach ($ids as $id) $idSql .= "," . $id;
|
|
|
- $idSql .= ")";
|
|
|
- $sql = DB::raw('select * from request where id not in ' . $idSql);
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $insert = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- if (!$param->status) continue;
|
|
|
- if (!$param->type) continue;
|
|
|
- if ($param->status == 0) $status = 10;
|
|
|
- if ($param->status == 1) $status = 0;
|
|
|
- if ($param->status == 2) $status = 1;
|
|
|
- if ($param->status == 3) $status = 2;
|
|
|
- if ($param->status == 4) $status = 11;
|
|
|
- if ($param->status == 5) $status = 4;
|
|
|
- if ($param->status == 6) $status = 5;
|
|
|
- if ($param->status == 7) $status = 6;
|
|
|
- if ($param->status == 8) $status = 8;
|
|
|
- if ($param->status == 9) $status = 9;
|
|
|
- if ($param->type == 3) {
|
|
|
- $type = 0;
|
|
|
- } else {
|
|
|
- $type = $param->type;
|
|
|
- }
|
|
|
- $insert[$param->id] = [
|
|
|
- 'id' => $param->id,
|
|
|
- 'code' => $param->number,
|
|
|
- 'type' => $type,
|
|
|
- 'owner_material_id' => $param->resourceid,
|
|
|
- 'quantity' => $param->num,
|
|
|
- 'amount' => $param->sellnum,
|
|
|
- 'unit_price' => $param->price,
|
|
|
- 'initiator' => 0,
|
|
|
- 'status' => $status,
|
|
|
- 'created_at' => Carbon::parse($param->createtime)->toDateTimeString(),
|
|
|
- 'updated_at' => Carbon::parse($param->createtime)->toDateTimeString(),
|
|
|
- 'deadline' => Carbon::parse($param->createtime)->subHours(-4)->toDateTimeString(),
|
|
|
- ];
|
|
|
- }
|
|
|
- Procurement::query()->insert($insert);
|
|
|
-
|
|
|
- //删除没有项目耗材的采购记录
|
|
|
- $OwnerMaterialIds = OwnerMaterial::query()->select('id')->get();
|
|
|
- $Procurements = Procurement::query()->whereNotIn('owner_material_id', $OwnerMaterialIds)->get();
|
|
|
- $data = [];
|
|
|
- foreach ($Procurements as $procurement) {
|
|
|
- $data[] = $procurement->owner_material_id;
|
|
|
- $procurement->delete();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function addProcurementQuotation()
|
|
|
- {
|
|
|
- //报价单
|
|
|
- $procurement_ids = Procurement::query()->select('id')->get();
|
|
|
- $ids = $procurement_ids->map(function ($procurement) {
|
|
|
- return $procurement['id'];
|
|
|
- });
|
|
|
- $idSql = "(''";
|
|
|
- foreach ($ids as $id) $idSql .= "," . $id;
|
|
|
- $idSql .= ")";
|
|
|
- $sql = DB::raw('SELECT purch.id id,request.id procurement_id,purch.supplierid supplier_id,
|
|
|
-purch.acceptprice offer,purch.accepttime quoted_at,purch.status status,
|
|
|
-purch.accepttime created_at,purch.accepttime updated_at
|
|
|
-FROM purch
|
|
|
-LEFT JOIN ask on purch.askid=ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where request.id in' . $idSql);
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- foreach ($params as $param) {
|
|
|
- $key = $param->id;
|
|
|
- $insert[$key] = [
|
|
|
- 'id' => $param->id,
|
|
|
- 'procurement_id' => $param->procurement_id,
|
|
|
- 'supplier_id' => $param->supplier_id,
|
|
|
- 'offer' => $param->offer,
|
|
|
- 'status' => $param->status,
|
|
|
- 'quoted_at' => Carbon::parse($param->quoted_at)->toDateTimeString(),
|
|
|
- 'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
|
|
|
- 'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementQuotation::query()->insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- public function addProcurementCheckSheet()
|
|
|
- {
|
|
|
- //对账单
|
|
|
- $procurement_delivers = ProcurementDeliverie::query()->get();
|
|
|
- $dataHandlerService = app(DataHandlerService::class);
|
|
|
- $procurement_delivers_map = $dataHandlerService->dataHeader(['procurement_id'], $procurement_delivers);
|
|
|
- $sql = DB::raw('select request.id procurement_id,billdetail.billno invoice_number,billdetail.status status,purch.acceptnum amount,purch.acceptprice price,
|
|
|
-purch.accepttime created_at,purch.accepttime updated_at
|
|
|
-FROM billdetail
|
|
|
-LEFT JOIN purch on purch.id=billdetail.purchid
|
|
|
-LEFT JOIN ask on purch.askid=ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where purch.islower=1');
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
-
|
|
|
- $insert = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- $procurement_deliver = $dataHandlerService->getKeyValue(['procurement_id' => $param->procurement_id], $procurement_delivers_map);
|
|
|
- if (!$procurement_deliver) continue;
|
|
|
- $insert[$param->procurement_id] = [
|
|
|
- 'procurement_delivery_id' => $procurement_deliver->id,
|
|
|
- 'invoice_number' => $param->invoice_number ?? null,
|
|
|
- 'account_payable' => $param->amount * $param->price,
|
|
|
- 'status' => $param->status,
|
|
|
- 'created_at' => $param->created_at,
|
|
|
- 'updated_at' => $param->updated_at,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementCheckSheet::query()->insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
public function order_packages_exception_type_sync()
|
|
|
{
|
|
|
$count = OrderPackage::query()->where('status', '派送异常')->update(['exception_type' => '派件异常', 'exception' => '是']);
|
|
|
@@ -1299,142 +988,9 @@ where purch.islower=1');
|
|
|
dump('更新了: ' . ($count_1 + $count_2));
|
|
|
}
|
|
|
|
|
|
- public function addProcurementDeliverAndCheckMeet()
|
|
|
- {
|
|
|
- $id = ProcurementDeliverie::query()->orderByDesc('id')->value('id');
|
|
|
- $sql = DB::raw('SELECT
|
|
|
-deliver.id id,request.id procurement_id,deliver.delivernum amount,deliver.status status,deliver.accepttime signed_at,
|
|
|
-deliver.createtime created_at,deliver.createtime updated_at,deliver.confirmnum receipt_amount
|
|
|
-from deliver
|
|
|
-LEFT JOIN purch on deliver.purchid=purch.id
|
|
|
-LEFT JOIN ask on purch.askid=ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where purch.islower=1 and deliver.id>' . $id);
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $insert = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- $insert[] = [
|
|
|
- 'id' => $param->id,
|
|
|
- 'procurement_id' => $param->procurement_id,
|
|
|
- 'amount' => $param->amount,
|
|
|
- 'status' => $param->status ? $param->status - 1 : $param->status,
|
|
|
- 'signed_at' => Carbon::parse($param->signed_at)->toDateString(),
|
|
|
- 'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
|
|
|
- 'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
|
|
|
- 'receipt_amount' => $param->receipt_amount,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementDeliverie::query()->insert($insert);
|
|
|
|
|
|
- $procurement_delivers = ProcurementDeliverie::query()->where('id', '>', $id)->get();
|
|
|
- $dataHandlerService = app(DataHandlerService::class);
|
|
|
- $procurement_delivers_map = $dataHandlerService->dataHeader(['procurement_id'], $procurement_delivers);
|
|
|
- $sql = DB::raw('SELECT deliver.id id,request.id procurement_id,
|
|
|
-deliver.createtime created_at,deliver.createtime updated_at,purch.acceptnum amount,purch.acceptprice price
|
|
|
-from deliver
|
|
|
-LEFT JOIN purch on deliver.purchid=purch.id
|
|
|
-LEFT JOIN ask on purch.askid=ask.id
|
|
|
-LEFT JOIN request on ask.requestid=request.id
|
|
|
-where purch.islower=1 and deliver.id>' . $id);
|
|
|
- $params = DB::connection('erp')->select($sql);
|
|
|
- $insert_ = [];
|
|
|
- foreach ($params as $param) {
|
|
|
- $procurement_deliver = $dataHandlerService->getKeyValue(['procurement_id' => $param->procurement_id], $procurement_delivers_map);
|
|
|
- if (!$procurement_deliver) continue;
|
|
|
- $insert_[$param->procurement_id] = [
|
|
|
- 'procurement_delivery_id' => $procurement_deliver->id,
|
|
|
- 'account_payable' => $param->amount * $param->price,
|
|
|
- 'status' => 0,
|
|
|
- 'created_at' => $param->created_at,
|
|
|
- 'updated_at' => $param->updated_at,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementCheckSheet::query()->insert($insert_);
|
|
|
- }
|
|
|
|
|
|
- public function updateProcurementCheckSheet()
|
|
|
- {
|
|
|
- $pro = ProcurementDeliverie::query()->find(515);
|
|
|
- $pro->update([
|
|
|
- 'signed_at' => '2021-04-02',
|
|
|
- 'created_at' => '2021-04-02 08:34:51',
|
|
|
- 'updated_at' => '2021-04-02 08:34:51',
|
|
|
- ]);
|
|
|
- $pro = $pro->loadMissing('procurement');
|
|
|
- ProcurementCheckSheet::query()->create([
|
|
|
- 'procurement_delivery_id' => $pro['id'],
|
|
|
- 'account_payable' => $pro['procurement']['cost_price'] * $pro['receipt_amount'],
|
|
|
- 'created_at' => $pro['created_at'],
|
|
|
- 'updated_at' => $pro['updated_at'],
|
|
|
- ]);
|
|
|
- $collect = ProcurementDeliverie::query()->with('procurement')->where('id', '>=', 517)
|
|
|
- ->where('id', '<=', 528)->get();
|
|
|
- $insert = [];
|
|
|
|
|
|
- foreach ($collect as $item) {
|
|
|
- if ($item['receipt_amount'] == 0) {
|
|
|
- $receipt_amount = $item['amount'];
|
|
|
- } else {
|
|
|
- $receipt_amount = $item['receipt_amount'];
|
|
|
- }
|
|
|
- $insert[] = [
|
|
|
- 'procurement_delivery_id' => $item['id'],
|
|
|
- 'account_payable' => $item['procurement']['cost_price'] * $receipt_amount,
|
|
|
- 'created_at' => $item['created_at'],
|
|
|
- 'updated_at' => $item['updated_at'],
|
|
|
- ];
|
|
|
- }
|
|
|
- ProcurementCheckSheet::query()->insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- public function testPro()
|
|
|
- {
|
|
|
- /**@var SupplierService $supplierService */
|
|
|
- $supplierService = app(SupplierService::class);
|
|
|
- $supplier_ids = $supplierService->screenSupplierIds();
|
|
|
-// $status=0;
|
|
|
-// $procurements=Procurement::query()
|
|
|
-// ->withCount('procurementQuotations')
|
|
|
-// ->with('ownerMaterial.material')
|
|
|
-// ->where('status',$status)
|
|
|
-// ->whereHas("ownerMaterial",function (Builder $query)use($supplier_ids){
|
|
|
-// $query->whereHas("material",function (Builder $query)use($supplier_ids){
|
|
|
-// $query->whereHas("supplier",function (Builder $query)use($supplier_ids){
|
|
|
-// $query->whereIn('id',$supplier_ids);
|
|
|
-// });
|
|
|
-// });
|
|
|
-// })
|
|
|
-// ->get();
|
|
|
-// $keys = [];
|
|
|
-// foreach ($procurements as $key=>$procurement){
|
|
|
-//// if ($procurement->procurement_quotations_count>0 && $status==0 )$keys[]= $key;
|
|
|
-// if ($procurement->type==2 && $procurement->supplier_id )$keys[]= $key;
|
|
|
-// if (Carbon::parse($procurement->deadline)->gt(Carbon::now())) $procurement->deadline=Carbon::parse($procurement->deadline)->diffInMilliseconds();
|
|
|
-// else $procurement->deadline=0;
|
|
|
-// }
|
|
|
-// $procurements = $procurements->diffKeys($keys);
|
|
|
-// dd($procurements);
|
|
|
- $status = 0;//0:待报价,2:待接单
|
|
|
- $procurements = Procurement::query()
|
|
|
- ->withCount('procurementQuotations')
|
|
|
- ->with(['ownerMaterial.material', 'procurementQuotations'])
|
|
|
- ->where('status', $status)
|
|
|
- ->get();
|
|
|
- dd($procurements);
|
|
|
- $keys = [];
|
|
|
- foreach ($procurements as $key => $procurement) {
|
|
|
- if ($procurement->procurement_quotations_count > 0) {
|
|
|
- foreach ($procurement->procurementQuotations as $procurementQuotation) {
|
|
|
- if (in_array($procurementQuotation->supplier_id, $supplier_ids)) $keys[] = $key;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($procurement->type == 2 && $procurement->supplier_id) $keys[] = $key;
|
|
|
- if (Carbon::parse($procurement->deadline)->gt(Carbon::now())) $procurement->deadline = Carbon::parse($procurement->deadline)->diffInMilliseconds();
|
|
|
- else $procurement->deadline = 0;
|
|
|
- }
|
|
|
- $procurements = $procurements->diffKeys($keys);
|
|
|
- dd($procurements);
|
|
|
- }
|
|
|
|
|
|
public function pushToWmsWeight()
|
|
|
{
|
|
|
@@ -1719,20 +1275,32 @@ TEXT;
|
|
|
dd($result);
|
|
|
}
|
|
|
|
|
|
- //更新入库近15天详情
|
|
|
- public function updateStoreItem()
|
|
|
- {
|
|
|
- ini_set('max_execution_time', 2 * 60 * 60);
|
|
|
- ini_set('memory_limit', '1024M');
|
|
|
- $last_time=Carbon::now()->subDays(7)->toDateTimeString();
|
|
|
- /** @var OracleDocAsnHerderService $oracleDocAsnHerderService */
|
|
|
- /** @var StoreItemService $storeItemService */
|
|
|
- $storeItemService = app(StoreItemService::class);
|
|
|
- $oracleDocAsnHerderService = app(OracleDocAsnHerderService::class);
|
|
|
- $asnHerdersCreated = $oracleDocAsnHerderService->getWmsAsnOnStartDateCreate($last_time);
|
|
|
- $storeItemService->storeItemUpdateByWms($asnHerdersCreated);
|
|
|
- $asnHerdersUpdated = $oracleDocAsnHerderService->getWmsAsnOnStartDateEdit($last_time);
|
|
|
- $storeItemService->storeItemUpdateByWms($asnHerdersUpdated);
|
|
|
+ public function createProcurementTotalBill()
|
|
|
+ {
|
|
|
+ $date='2021-05';
|
|
|
+ $procurementCheckSheets=ProcurementCheckSheet::query()
|
|
|
+ ->selectRaw('procurements.supplier_id supplier_id,procurement_check_sheets.created_at created_at,procurement_check_sheets.status status,SUM(procurement_check_sheets.account_payable) account_payable')
|
|
|
+ ->leftJoin('procurement_deliveries','procurement_check_sheets.procurement_delivery_id','procurement_deliveries.id')
|
|
|
+ ->leftJoin('procurements','procurement_deliveries.procurement_id','procurements.id')
|
|
|
+ ->where('procurement_check_sheets.created_at','like',$date."%")
|
|
|
+ ->groupBy('supplier_id')->where('procurements.supplier_id',84)
|
|
|
+ ->get();
|
|
|
+ $totalBill=[];
|
|
|
+ foreach ($procurementCheckSheets as $procurementCheckSheet){
|
|
|
+ if ($procurementCheckSheet->account_payable<1) continue;
|
|
|
+ $totalBill[]=[
|
|
|
+ 'counting_month'=>$date.'-01',
|
|
|
+ 'supplier_id'=>$procurementCheckSheet->supplier_id,
|
|
|
+ 'total_payable'=>$procurementCheckSheet->account_payable,
|
|
|
+ 'status'=>$procurementCheckSheet->status,
|
|
|
+ 'created_at'=>date('2021-06-01 00:00:00'),
|
|
|
+ 'updated_at'=>date('2021-06-01 00:00:00'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if (count($totalBill)>0){
|
|
|
+ DB::table("procurement_total_bills")->insert($totalBill);
|
|
|
+ app('LogService')->log(__METHOD__,"采购管理-生成月账单报表",json_encode($totalBill));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function test_ang()
|