Database Queries

总计14条数据
TimeDurationTypeQuery
  
14:53:34.9842.2 msSELECTSELECT * FROM "global"."vw_user_login" WHERE "id"=1001

14:53:34.9871.5 msSELECTSELECT * FROM "a57be577deb434"."tbl_users" WHERE "id"=1001

14:53:34.9923.6 msSELECTSELECT COUNT(*) FROM (SELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC) "c"

14:53:34.9971.6 msSELECTSELECT SUM(budget) FROM (SELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC) "c"

14:53:34.9991.6 msSELECTSELECT SUM(budget / 100 * profit_pct) FROM (SELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC) "c"

14:53:35.0011.5 msSELECTSELECT SUM(collected) FROM (SELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC) "c"

14:53:35.0031.5 msSELECTSELECT COUNT(*) FROM (SELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC) "c"

14:53:35.00526.3 msSELECTSELECT (final.pstime + final.irtime) AS service_time, (final.pscount + final.ircount) AS service_count, final.* FROM (SELECT CASE WHEN tmp1.pre_sales_counts IS NULL THEN 0 ELSE tmp1.pre_sales_counts END AS pscount, CASE WHEN tmp2.implement_counts IS NULL THEN 0 ELSE tmp2.implement_counts END AS ircount, CASE WHEN tmp1.pre_sales_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp1.pre_sales_times)/3600 ELSE 0 END AS pstime, CASE WHEN tmp2.implement_times IS NOT NULL THEN EXTRACT(EPOCH FROM tmp2.implement_times)/3600 ELSE 0 END AS irtime, CASE WHEN tmp3.points IS NOT NULL THEN tmp3.points ELSE 0 END AS points, CASE WHEN tmp4.work_times IS NOT NULL THEN tmp4.work_times ELSE '00:00:00'::interval END AS work_time, CASE WHEN tmp4.work_count IS NOT NULL THEN tmp4.work_count ELSE 0 END AS work_count, CASE WHEN tmp5.reimbursement_amount IS NOT NULL THEN tmp5.reimbursement_amount ELSE 0 END AS reimbursement_amount, p.*, p.budget * profit_pct / 100 AS profits, p.budget - p.collected AS un_collected FROM "a57be577deb434"."tbl_projects" "p" LEFT JOIN (SELECT sub1.project_id, count(sub1.id) as pre_sales_counts, sum(sub1.pre_sales_time) as pre_sales_times FROM (SELECT "ps"."id", "c"."project_id", (ps.end_at - ps.start_at) as pre_sales_time FROM "a57be577deb434"."tbl_pre_sales" "ps" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ps.case_id = c.id WHERE "ps"."is_draft"=FALSE) "sub1" GROUP BY "sub1"."project_id") "tmp1" ON tmp1.project_id = p.id LEFT JOIN (SELECT sub2.project_id, count(sub2.id) as implement_counts, sum(sub2.implement_time) as implement_times FROM (SELECT "ir"."id", "c"."project_id", (ir.left_at - ir.arrived_at) as implement_time FROM "a57be577deb434"."tbl_implement_records" "ir" LEFT JOIN "a57be577deb434"."tbl_cases" "c" ON ir.case_id = c.id WHERE "ir"."is_draft"=FALSE) "sub2" GROUP BY "sub2"."project_id") "tmp2" ON tmp2.project_id = p.id LEFT JOIN (SELECT sub3.project_id, sum(sub3.points) as points FROM (SELECT "c"."project_id", sum(ca.points) as points FROM "a57be577deb434"."tbl_cases" "c" LEFT JOIN "a57be577deb434"."tbl_case_assignments" "ca" ON ca.case_id = c.id GROUP BY "c"."id") "sub3" GROUP BY "sub3"."project_id") "tmp3" ON tmp3.project_id = p.id LEFT JOIN (SELECT sub4.project_id, count(sub4.id) as work_count, sum(sub4.work_time) as work_times FROM (SELECT "wl"."id", "wl"."project_id", (wl.end_at - wl.start_at) as work_time FROM "a57be577deb434"."tbl_work_logs" "wl" WHERE ("wl"."is_draft"=FALSE) AND ("wl"."location_in_id" IS NOT NULL) AND ("wl"."location_out_id" IS NOT NULL) AND ("wl"."client_id" IS NOT NULL)) "sub4" GROUP BY "sub4"."project_id") "tmp4" ON tmp4.project_id = p.id LEFT JOIN (SELECT sub5.project_id, sum(sub5.reimbursement_amount) as reimbursement_amount FROM (SELECT "r"."project_id", "r"."amount" AS "reimbursement_amount" FROM "a57be577deb434"."tbl_reimbursements" "r" WHERE "r"."status" IN (2, 3)) "sub5" GROUP BY "sub5"."project_id") "tmp5" ON tmp5.project_id = p.id WHERE ("p"."created_by" IN (1001, 5049, 5301, 5022, 5209, 5026, 5293, 5309, 5356, 5329, 5299, 5303, 5302, 5332, 5047, 1026, 5096, 5070, 5448, 5420, 1029, 5037, 5087, 1008, 5048, 5043, 5045, 5230, 5031, 5088, 5208, 1003, 5294, 5357, 5044, 1030, 5076, 5300, 5027, 5089, 5311, 5066, 5069, 5364, 1009, 5295, 1013, 5128, 5203, 1025, 5032, 5075, 1004, 5072, 5033, 5359, 5412, 5409, 5229, 1005, 5304, 5449, 5358, 1006, 5093)) AND ("p"."client_id"='2115') AND ("p"."project_status"='3') AND (p.collected < p.budget)) "final" ORDER BY "bargain_date" DESC LIMIT 20

14:53:35.0310.6 msSELECTSELECT "id", "id" AS "key", "name", "logo", "client_type", "client_class", "client_industry" FROM "a57be577deb434"."tbl_clients" WHERE "id"=2115

14:53:35.0320.2 msSELECTSELECT "id", "id" AS "key", "name", "sex", "department_id" FROM "a57be577deb434"."tbl_users" WHERE "id"=1001

14:53:35.0330.6 msSELECTSELECT "id", "user_id", "meta_value" AS "name" FROM "a57be577deb434"."tbl_user_meta" WHERE ("meta_key"='avatar') AND ("user_id"=1001)

14:53:35.0343.6 msSELECTSELECT * FROM "a57be577deb434"."tbl_visit_module_histories" WHERE ("user_id"=1001) AND ("object_type"=23) AND ("visit_date"='2025-08-21')

14:53:35.0380.9 msUPDATEUPDATE "a57be577deb434"."tbl_visit_module_histories" SET "num"=20, "last_visit_at"='now()' WHERE "id"=55357

14:53:35.0391.1 msINSERTINSERT INTO "global"."tbl_api_log" ("code", "schema", "user_id", "device_type", "url", "request", "response", "php_error", "time") VALUES (200, 'a57be577deb434', 1001, 5, 'vue/analysis/sales-project-list', '{"client_id":"2115","page":"1","status":"un_collected","web_access_token":"239qcuu_ToIhJtTt60gp-9_fllLTtTgq"}', '{"code":2000,"result":{"list":[{"service_time":"0","service_count":0,"pscount":0,"ircount":0,"pstime":"0","irtime":"0","points":0,"work_time":0,"work_count":0,"reimbursement_amount":"0","id":2684,"client_id":2115,"project_status":3,"project_progress":10,"budget":"2648000","profit_pct":"1.48","bargain_date":"2021-11-22","description":"\u6c5f\u5357\u79d1\u53cb\u4ea7\u54c1","created_by":1001,"created_at":"2021-11-10 15:11:08","updated_at":"2025-07-29 10:51:48","engineer_id":null,"project_title":"\u56fd\u5bc6\u4e8c\u671f\u9879\u76ee","collected":"2621954","status_updated_at":"2022-10-26 12:58:21.848439+08","success_rate":null,"comment":"\u6c5f\u5357\u79d1\u53cb\u4ea7\u54c1\r\n","contract_type":1,"progress_updated_at":"2022-10-26 12:58:21.848439+08","forecast_updated_at":"2022-10-26 12:58:21.848439+08","end_at":"","pinyin_shortcut":"gmeqxm","creator":1001,"used_client":null,"from_contact":null,"total_contact_point":null,"paid_contact_point":null,"project_product_version_id":null,"is_sales_order_ready":false,"collected_plan":"2648000","change_status_to":null,"is_verify":false,"profits":"39190.400000000000","un_collected":"26046","client":{"id":2115,"key":2115,"name":"\u5409\u6797\u7701\u519c\u6751\u4fe1\u7528\u793e\u8054\u5408\u793e","logo":null,"client_type":6,"client_class":43,"client_industry":10},"createdBy":{"id":1001,"key":1001,"name":"\u5218\u4eba\u8bda","sex":"M","department_id":4,"avatar":{"id":2,"user_id":1001,"name":"\/files\/cdn\/a57be577deb434\/avatar\/9f73cfbd-bae6-3b50-b7ac-61b936c40727.png"}}}],"count":1,"sumBudget":"2648000","sumProfit":39190.4,"sumCollect":"2621954","pagenation":{"totalcount":1,"thispage":1,"pagesize":20}},"status":1,"msg":[{"name":"success","success":"\u6210\u529f\u83b7\u53d6\u6570\u636e","error":""}],"mod":0}', FALSE, '2025-08-21 14:53:35') RETURNING "id"